mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: use vim.mpack and vim.uv directly
This commit is contained in:
parent
56a2ec5c79
commit
284e0ad26d
@ -1,4 +1,4 @@
|
||||
local mpack = require('mpack')
|
||||
local mpack = vim.mpack
|
||||
|
||||
-- temporary hack to be able to manipulate buffer/window/tabpage
|
||||
local Buffer = {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
local uv = require('luv')
|
||||
local uv = vim.uv
|
||||
local MsgpackRpcStream = require('test.client.msgpack_rpc_stream')
|
||||
|
||||
local Session = {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
local uv = require('luv')
|
||||
local uv = vim.uv
|
||||
|
||||
local StdioStream = {}
|
||||
StdioStream.__index = StdioStream
|
||||
|
@ -1,5 +1,4 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local mpack = require('mpack')
|
||||
local clear, funcs, eq = helpers.clear, helpers.funcs, helpers.eq
|
||||
local call = helpers.call
|
||||
local meths = helpers.meths
|
||||
@ -12,7 +11,7 @@ local function read_mpack_file(fname)
|
||||
|
||||
local data = fd:read('*a')
|
||||
fd:close()
|
||||
local unpack = mpack.Unpacker()
|
||||
local unpack = vim.mpack.Unpacker()
|
||||
return unpack(data)
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
local luv = require('luv')
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local clear = helpers.clear
|
||||
@ -9,7 +8,7 @@ local request = helpers.request
|
||||
local is_os = helpers.is_os
|
||||
|
||||
describe('autocmd DirChanged and DirChangedPre', function()
|
||||
local curdir = string.gsub(luv.cwd(), '\\', '/')
|
||||
local curdir = vim.uv.cwd():gsub('\\', '/')
|
||||
local dirs = {
|
||||
curdir .. '/Xtest-functional-autocmd-dirchanged.dir1',
|
||||
curdir .. '/Xtest-functional-autocmd-dirchanged.dir2',
|
||||
|
@ -1,6 +1,5 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local thelpers = require('test.functional.terminal.helpers')
|
||||
local luv = require('luv')
|
||||
local clear = helpers.clear
|
||||
local feed_command = helpers.feed_command
|
||||
local feed_data = thelpers.feed_data
|
||||
@ -42,7 +41,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
|
||||
|
||||
helpers.write_file(path, '')
|
||||
local atime = os.time() - 10
|
||||
luv.fs_utime(path, atime, atime)
|
||||
vim.uv.fs_utime(path, atime, atime)
|
||||
|
||||
screen:expect {
|
||||
grid = [[
|
||||
|
@ -1,4 +1,4 @@
|
||||
local luv = require('luv')
|
||||
local uv = vim.uv
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local thelpers = require('test.functional.terminal.helpers')
|
||||
|
||||
@ -78,14 +78,14 @@ describe('autocmd TermClose', function()
|
||||
eq(1, eval('get(g:, "test_job_started", 0)'))
|
||||
end)
|
||||
|
||||
luv.update_time()
|
||||
local start = luv.now()
|
||||
uv.update_time()
|
||||
local start = uv.now()
|
||||
command('call jobstop(g:test_job)')
|
||||
retry(nil, nil, function()
|
||||
eq(1, eval('get(g:, "test_job_exited", 0)'))
|
||||
end)
|
||||
luv.update_time()
|
||||
local duration = luv.now() - start
|
||||
uv.update_time()
|
||||
local duration = uv.now() - start
|
||||
-- Nvim begins SIGTERM after KILL_TIMEOUT_MS.
|
||||
ok(duration >= 2000)
|
||||
ok(duration <= 4000) -- Epsilon for slow CI
|
||||
@ -105,14 +105,14 @@ describe('autocmd TermClose', function()
|
||||
eq(1, eval('get(g:, "test_job_started", 0)'))
|
||||
end)
|
||||
|
||||
luv.update_time()
|
||||
local start = luv.now()
|
||||
uv.update_time()
|
||||
local start = uv.now()
|
||||
command('call jobstop(g:test_job)')
|
||||
retry(nil, nil, function()
|
||||
eq(1, eval('get(g:, "test_job_exited", 0)'))
|
||||
end)
|
||||
luv.update_time()
|
||||
local duration = luv.now() - start
|
||||
uv.update_time()
|
||||
local duration = uv.now() - start
|
||||
-- Nvim begins SIGKILL after (2 * KILL_TIMEOUT_MS).
|
||||
ok(duration >= 4000)
|
||||
ok(duration <= 7000) -- Epsilon for slow CI
|
||||
|
@ -1,4 +1,4 @@
|
||||
local luv = require('luv')
|
||||
local uv = vim.uv
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
@ -32,7 +32,7 @@ describe('command-line option', function()
|
||||
end)
|
||||
|
||||
it('treats - as stdin', function()
|
||||
eq(nil, luv.fs_stat(fname))
|
||||
eq(nil, uv.fs_stat(fname))
|
||||
funcs.system({
|
||||
nvim_prog_abs(),
|
||||
'-u',
|
||||
@ -47,12 +47,12 @@ describe('command-line option', function()
|
||||
fname,
|
||||
}, { ':call setline(1, "42")', ':wqall!', '' })
|
||||
eq(0, eval('v:shell_error'))
|
||||
local attrs = luv.fs_stat(fname)
|
||||
local attrs = uv.fs_stat(fname)
|
||||
eq(#'42\n', attrs.size)
|
||||
end)
|
||||
|
||||
it('does not expand $VAR', function()
|
||||
eq(nil, luv.fs_stat(fname))
|
||||
eq(nil, uv.fs_stat(fname))
|
||||
eq(true, not not dollar_fname:find('%$%w+'))
|
||||
write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n')
|
||||
funcs.system({
|
||||
@ -69,7 +69,7 @@ describe('command-line option', function()
|
||||
fname,
|
||||
})
|
||||
eq(0, eval('v:shell_error'))
|
||||
local attrs = luv.fs_stat(fname)
|
||||
local attrs = uv.fs_stat(fname)
|
||||
eq(#'100500\n', attrs.size)
|
||||
end)
|
||||
|
||||
@ -170,7 +170,7 @@ describe('command-line option', function()
|
||||
})
|
||||
)
|
||||
eq(2, eval('v:shell_error'))
|
||||
eq(nil, luv.fs_stat(fname_2))
|
||||
eq(nil, uv.fs_stat(fname_2))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
-- Specs for :cd, :tcd, :lcd and getcwd()
|
||||
|
||||
local luv = require('luv')
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local eq = helpers.eq
|
||||
@ -56,7 +55,7 @@ for _, cmd in ipairs { 'cd', 'chdir' } do
|
||||
|
||||
after_each(function()
|
||||
for _, d in pairs(directories) do
|
||||
luv.fs_rmdir(d)
|
||||
vim.uv.fs_rmdir(d)
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local eq = helpers.eq
|
||||
@ -8,7 +7,7 @@ local rmdir = helpers.rmdir
|
||||
local mkdir = helpers.mkdir
|
||||
|
||||
describe(':file', function()
|
||||
local swapdir = luv.cwd() .. '/Xtest-file_spec'
|
||||
local swapdir = vim.uv.cwd() .. '/Xtest-file_spec'
|
||||
before_each(function()
|
||||
clear()
|
||||
rmdir(swapdir)
|
||||
|
@ -1,5 +1,5 @@
|
||||
require('os')
|
||||
local luv = require('luv')
|
||||
local uv = vim.uv
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local eval = helpers.eval
|
||||
@ -12,16 +12,16 @@ local read_file = helpers.read_file
|
||||
|
||||
-- tmpname() also creates the file on POSIX systems. Remove it again.
|
||||
-- We just need the name, ignoring any race conditions.
|
||||
if luv.fs_stat(tempfile).uid then
|
||||
if uv.fs_stat(tempfile).uid then
|
||||
os.remove(tempfile)
|
||||
end
|
||||
|
||||
local function assert_file_exists(filepath)
|
||||
neq(nil, luv.fs_stat(filepath).uid)
|
||||
neq(nil, uv.fs_stat(filepath).uid)
|
||||
end
|
||||
|
||||
local function assert_file_exists_not(filepath)
|
||||
eq(nil, luv.fs_stat(filepath))
|
||||
eq(nil, uv.fs_stat(filepath))
|
||||
end
|
||||
|
||||
describe(':profile', function()
|
||||
@ -29,7 +29,7 @@ describe(':profile', function()
|
||||
|
||||
after_each(function()
|
||||
helpers.expect_exit(command, 'qall!')
|
||||
if luv.fs_stat(tempfile).uid ~= nil then
|
||||
if uv.fs_stat(tempfile).uid ~= nil then
|
||||
os.remove(tempfile)
|
||||
end
|
||||
end)
|
||||
|
@ -1,5 +1,4 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
local eq, eval, clear, write_file, source, insert =
|
||||
helpers.eq, helpers.eval, helpers.clear, helpers.write_file, helpers.source, helpers.insert
|
||||
local pcall_err = helpers.pcall_err
|
||||
@ -159,7 +158,7 @@ describe(':write', function()
|
||||
end
|
||||
write_file(fname_bak, 'TTYX')
|
||||
skip(is_os('win'), [[FIXME: exc_exec('write!') outputs 0 in Windows]])
|
||||
luv.fs_symlink(fname_bak .. ('/xxxxx'):rep(20), fname)
|
||||
vim.uv.fs_symlink(fname_bak .. ('/xxxxx'):rep(20), fname)
|
||||
eq("Vim(write):E166: Can't open linked file for writing", pcall_err(command, 'write!'))
|
||||
end)
|
||||
end)
|
||||
|
@ -1,5 +1,4 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
local clear = helpers.clear
|
||||
local command, eq, neq, write_file = helpers.command, helpers.eq, helpers.neq, helpers.write_file
|
||||
local read_file = helpers.read_file
|
||||
@ -26,10 +25,10 @@ describe(':wshada', function()
|
||||
|
||||
it('creates a shada file', function()
|
||||
-- file should _not_ exist
|
||||
eq(nil, luv.fs_stat(shada_file))
|
||||
eq(nil, vim.uv.fs_stat(shada_file))
|
||||
command('wsh! ' .. shada_file)
|
||||
-- file _should_ exist
|
||||
neq(nil, luv.fs_stat(shada_file))
|
||||
neq(nil, vim.uv.fs_stat(shada_file))
|
||||
end)
|
||||
|
||||
it('overwrites existing files', function()
|
||||
@ -40,7 +39,7 @@ describe(':wshada', function()
|
||||
|
||||
-- sanity check
|
||||
eq(text, read_file(shada_file))
|
||||
neq(nil, luv.fs_stat(shada_file))
|
||||
neq(nil, vim.uv.fs_stat(shada_file))
|
||||
|
||||
command('wsh! ' .. shada_file)
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
-- being modified outside of Vim (noticed on Solaris).
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
local clear, feed_command, expect, eq, neq, dedent, write_file, feed =
|
||||
helpers.clear,
|
||||
helpers.feed_command,
|
||||
@ -37,8 +36,8 @@ local function prepare_gz_file(name, text)
|
||||
-- Compress the file with gzip.
|
||||
command([[call system(['gzip', '--force', ']] .. name .. [['])]])
|
||||
-- This should create the .gz file and delete the original.
|
||||
neq(nil, luv.fs_stat(name .. '.gz'))
|
||||
eq(nil, luv.fs_stat(name))
|
||||
neq(nil, vim.uv.fs_stat(name .. '.gz'))
|
||||
eq(nil, vim.uv.fs_stat(name))
|
||||
end
|
||||
|
||||
describe('file reading, writing and bufnew and filter autocommands', function()
|
||||
|
@ -4,7 +4,6 @@
|
||||
-- - "dir", in directory relative to current dir
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
|
||||
local eq = helpers.eq
|
||||
local neq = helpers.neq
|
||||
@ -62,21 +61,21 @@ describe("'directory' option", function()
|
||||
meths.set_option_value('directory', '.', {})
|
||||
|
||||
-- sanity check: files should not exist yet.
|
||||
eq(nil, luv.fs_stat('.Xtest1.swp'))
|
||||
eq(nil, vim.uv.fs_stat('.Xtest1.swp'))
|
||||
|
||||
command('edit! Xtest1')
|
||||
poke_eventloop()
|
||||
eq('Xtest1', funcs.buffer_name('%'))
|
||||
-- Verify that the swapfile exists. In the legacy test this was done by
|
||||
-- reading the output from :!ls.
|
||||
neq(nil, luv.fs_stat('.Xtest1.swp'))
|
||||
neq(nil, vim.uv.fs_stat('.Xtest1.swp'))
|
||||
|
||||
meths.set_option_value('directory', './Xtest2,.', {})
|
||||
command('edit Xtest1')
|
||||
poke_eventloop()
|
||||
|
||||
-- swapfile should no longer exist in CWD.
|
||||
eq(nil, luv.fs_stat('.Xtest1.swp'))
|
||||
eq(nil, vim.uv.fs_stat('.Xtest1.swp'))
|
||||
|
||||
eq({ 'Xtest1.swp', 'Xtest3' }, ls_dir_sorted('Xtest2'))
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
-- Tests for storing global variables in the .shada file
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
local clear, command, eq, neq, eval, poke_eventloop =
|
||||
helpers.clear, helpers.command, helpers.eq, helpers.neq, helpers.eval, helpers.poke_eventloop
|
||||
|
||||
@ -134,7 +133,7 @@ describe('storing global variables in ShaDa files', function()
|
||||
poke_eventloop()
|
||||
|
||||
-- Assert that the shada file exists.
|
||||
neq(nil, luv.fs_stat(tempname))
|
||||
neq(nil, vim.uv.fs_stat(tempname))
|
||||
command('unlet MY_GLOBAL_DICT')
|
||||
command('unlet MY_GLOBAL_LIST')
|
||||
-- Assert that the variables where deleted.
|
||||
|
@ -1,6 +1,5 @@
|
||||
-- Test suite for testing interactions with API bindings
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
|
||||
local command = helpers.command
|
||||
local meths = helpers.meths
|
||||
@ -777,7 +776,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
||||
old line 2]]
|
||||
)
|
||||
local atime = os.time() - 10
|
||||
luv.fs_utime('Xtest-reload', atime, atime)
|
||||
vim.uv.fs_utime('Xtest-reload', atime, atime)
|
||||
command 'e Xtest-reload'
|
||||
command 'set autoread'
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local uv = require('luv')
|
||||
|
||||
local clear = helpers.clear
|
||||
local exec_lua = helpers.exec_lua
|
||||
@ -293,7 +292,7 @@ describe('vim.fs', function()
|
||||
eq('/', vim.fs.normalize('/'))
|
||||
end)
|
||||
it('works with ~', function()
|
||||
eq(vim.fs.normalize(uv.os_homedir()) .. '/src/foo', vim.fs.normalize('~/src/foo'))
|
||||
eq(vim.fs.normalize(vim.uv.os_homedir()) .. '/src/foo', vim.fs.normalize('~/src/foo'))
|
||||
end)
|
||||
it('works with environment variables', function()
|
||||
local xdg_config_home = test_build_dir .. '/.config'
|
||||
|
@ -24,13 +24,11 @@ describe('vim.uv', function()
|
||||
exec_lua('vim.api.nvim_set_var("coroutine_cnt", 0)', {})
|
||||
|
||||
local code = [[
|
||||
local uv = vim.uv
|
||||
|
||||
local touch = 0
|
||||
local function wait(ms)
|
||||
local this = coroutine.running()
|
||||
assert(this)
|
||||
local timer = uv.new_timer()
|
||||
local timer = vim.uv.new_timer()
|
||||
timer:start(ms, 0, vim.schedule_wrap(function ()
|
||||
timer:close()
|
||||
touch = touch + 1
|
||||
|
@ -1,4 +1,3 @@
|
||||
local luv = require('luv')
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear = helpers.clear
|
||||
local eq = helpers.eq
|
||||
@ -21,7 +20,7 @@ describe("'autochdir'", function()
|
||||
end)
|
||||
|
||||
it('is not overwritten by getwinvar() call #17609', function()
|
||||
local curdir = string.gsub(luv.cwd(), '\\', '/')
|
||||
local curdir = vim.uv.cwd():gsub('\\', '/')
|
||||
local dir_a = curdir .. '/Xtest-functional-options-autochdir.dir_a'
|
||||
local dir_b = curdir .. '/Xtest-functional-options-autochdir.dir_b'
|
||||
mkdir(dir_a)
|
||||
|
@ -14,8 +14,6 @@ local eq, meths, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curb
|
||||
local neq = helpers.neq
|
||||
local read_file = helpers.read_file
|
||||
|
||||
local mpack = require('mpack')
|
||||
|
||||
local shada_helpers = require('test.functional.shada.helpers')
|
||||
local get_shada_rw = shada_helpers.get_shada_rw
|
||||
|
||||
@ -26,7 +24,7 @@ end
|
||||
local mpack_eq = function(expected, mpack_result)
|
||||
local mpack_keys = { 'type', 'timestamp', 'length', 'value' }
|
||||
|
||||
local unpack = mpack.Unpacker()
|
||||
local unpack = vim.mpack.Unpacker()
|
||||
local actual = {}
|
||||
local cur, val
|
||||
local i = 0
|
||||
|
@ -3,8 +3,6 @@ local meths = helpers.meths
|
||||
local write_file = helpers.write_file
|
||||
local concat_tables = helpers.concat_tables
|
||||
|
||||
local mpack = require('mpack')
|
||||
|
||||
local tmpname = helpers.tmpname()
|
||||
|
||||
-- o={
|
||||
@ -64,7 +62,7 @@ local read_shada_file = function(fname)
|
||||
local fd = io.open(fname, 'r')
|
||||
local mstring = fd:read('*a')
|
||||
fd:close()
|
||||
local unpack = mpack.Unpacker()
|
||||
local unpack = vim.mpack.Unpacker()
|
||||
local ret = {}
|
||||
local cur, val
|
||||
local i = 0
|
||||
|
@ -6,11 +6,9 @@ local write_file, spawn, set_session, nvim_prog, exc_exec =
|
||||
local is_os = helpers.is_os
|
||||
local skip = helpers.skip
|
||||
|
||||
local luv = require('luv')
|
||||
local uv = vim.uv
|
||||
local paths = require('test.cmakeconfig.paths')
|
||||
|
||||
local mpack = require('mpack')
|
||||
|
||||
local shada_helpers = require('test.functional.shada.helpers')
|
||||
local reset, clear, get_shada_rw =
|
||||
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
|
||||
@ -26,7 +24,7 @@ describe('ShaDa support code', function()
|
||||
after_each(function()
|
||||
clear()
|
||||
clean()
|
||||
luv.fs_rmdir(dirname)
|
||||
uv.fs_rmdir(dirname)
|
||||
end)
|
||||
|
||||
it('preserves `s` item size limit with unknown entries', function()
|
||||
@ -87,7 +85,7 @@ describe('ShaDa support code', function()
|
||||
wshada('Some text file')
|
||||
eq(0, exc_exec('wshada! ' .. shada_fname))
|
||||
eq(1, read_shada_file(shada_fname)[1].type)
|
||||
eq(nil, luv.fs_stat(shada_fname .. '.tmp.a'))
|
||||
eq(nil, uv.fs_stat(shada_fname .. '.tmp.a'))
|
||||
end
|
||||
)
|
||||
|
||||
@ -148,11 +146,11 @@ describe('ShaDa support code', function()
|
||||
wshada(s .. table.concat(msgpack, e .. s) .. e)
|
||||
eq(0, exc_exec('wshada ' .. shada_fname))
|
||||
local found = 0
|
||||
local typ = mpack.decode(s)
|
||||
local typ = vim.mpack.decode(s)
|
||||
for _, v in ipairs(read_shada_file(shada_fname)) do
|
||||
if v.type == typ then
|
||||
found = found + 1
|
||||
eq(mpack.decode(msgpack[found]), v.timestamp)
|
||||
eq(vim.mpack.decode(msgpack[found]), v.timestamp)
|
||||
end
|
||||
end
|
||||
eq(#msgpack, found)
|
||||
@ -279,8 +277,8 @@ describe('ShaDa support code', function()
|
||||
true
|
||||
)
|
||||
session:close()
|
||||
eq(nil, luv.fs_stat('NONE'))
|
||||
eq(nil, luv.fs_stat('NONE.tmp.a'))
|
||||
eq(nil, uv.fs_stat('NONE'))
|
||||
eq(nil, uv.fs_stat('NONE.tmp.a'))
|
||||
end)
|
||||
|
||||
it('does not read NONE file', function()
|
||||
|
@ -1,4 +1,4 @@
|
||||
local uv = require 'luv'
|
||||
local uv = vim.uv
|
||||
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
@ -1,7 +1,5 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
|
||||
local luv = require('luv')
|
||||
|
||||
local eq = helpers.eq
|
||||
local clear = helpers.clear
|
||||
local funcs = helpers.funcs
|
||||
@ -87,7 +85,7 @@ describe('bufname() function', function()
|
||||
it('returns expected buffer name', function()
|
||||
eq('', funcs.bufname('%')) -- Buffer has no name yet
|
||||
command('file ' .. fname)
|
||||
local wd = luv.cwd()
|
||||
local wd = vim.uv.cwd()
|
||||
local sep = get_pathsep()
|
||||
local curdirname = funcs.fnamemodify(wd, ':t')
|
||||
for _, arg in ipairs({ '%', 1, 'X', wd }) do
|
||||
@ -120,7 +118,7 @@ describe('bufnr() function', function()
|
||||
it('returns expected buffer number', function()
|
||||
eq(1, funcs.bufnr('%'))
|
||||
command('file ' .. fname)
|
||||
local wd = luv.cwd()
|
||||
local wd = vim.uv.cwd()
|
||||
local curdirname = funcs.fnamemodify(wd, ':t')
|
||||
eq(1, funcs.bufnr(fname))
|
||||
eq(1, funcs.bufnr(wd))
|
||||
|
@ -1,4 +1,3 @@
|
||||
local luv = require('luv')
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, command, eval, eq = helpers.clear, helpers.command, helpers.eval, helpers.eq
|
||||
local mkdir = helpers.mkdir
|
||||
@ -12,7 +11,7 @@ before_each(function()
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
luv.fs_rmdir('test-glob')
|
||||
vim.uv.fs_rmdir('test-glob')
|
||||
end)
|
||||
|
||||
describe('glob()', function()
|
||||
|
@ -62,8 +62,7 @@ describe('has()', function()
|
||||
end)
|
||||
|
||||
it('"wsl"', function()
|
||||
local luv = require('luv')
|
||||
local is_wsl = luv.os_uname()['release']:lower():match('microsoft') and true or false
|
||||
local is_wsl = vim.uv.os_uname()['release']:lower():match('microsoft') and true or false
|
||||
if is_wsl then
|
||||
eq(1, funcs.has('wsl'))
|
||||
else
|
||||
|
@ -1,5 +1,4 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local luv = require('luv')
|
||||
|
||||
local mkdir = helpers.mkdir
|
||||
local clear = helpers.clear
|
||||
@ -28,8 +27,8 @@ end)
|
||||
after_each(function()
|
||||
os.remove(fname)
|
||||
os.remove(dfname)
|
||||
luv.fs_rmdir(ddname)
|
||||
luv.fs_rmdir(dname)
|
||||
vim.uv.fs_rmdir(ddname)
|
||||
vim.uv.fs_rmdir(dname)
|
||||
end)
|
||||
|
||||
describe('writefile()', function()
|
||||
|
@ -1,4 +1,4 @@
|
||||
local luv = require('luv')
|
||||
local uv = vim.uv
|
||||
|
||||
local helpers = require('test.unit.helpers')(after_each)
|
||||
local itp = helpers.gen_itp(it)
|
||||
@ -36,8 +36,8 @@ before_each(function()
|
||||
f2:write(fcontents)
|
||||
f2:close()
|
||||
|
||||
luv.fs_symlink('file1.dat', linkf)
|
||||
luv.fs_symlink('broken.dat', linkb)
|
||||
uv.fs_symlink('file1.dat', linkf)
|
||||
uv.fs_symlink('broken.dat', linkb)
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
@ -46,7 +46,7 @@ after_each(function()
|
||||
os.remove(linkf)
|
||||
os.remove(linkb)
|
||||
os.remove(filec)
|
||||
luv.fs_rmdir(dir)
|
||||
uv.fs_rmdir(dir)
|
||||
end)
|
||||
|
||||
local function file_open(fname, flags, mode)
|
||||
@ -120,13 +120,13 @@ describe('file_open_fd', function()
|
||||
eq(0, m.file_close(fp, false))
|
||||
end)
|
||||
itp('can use file descriptor returned by os_open for writing', function()
|
||||
eq(nil, luv.fs_stat(filec))
|
||||
eq(nil, uv.fs_stat(filec))
|
||||
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
|
||||
local err, fp = file_open_fd(fd, m.kFileWriteOnly)
|
||||
eq(0, err)
|
||||
eq(4, file_write(fp, 'test'))
|
||||
eq(0, m.file_close(fp, false))
|
||||
eq(4, luv.fs_stat(filec).size)
|
||||
eq(4, uv.fs_stat(filec).size)
|
||||
eq('test', io.open(filec):read('*a'))
|
||||
end)
|
||||
end)
|
||||
@ -140,13 +140,13 @@ describe('file_open_fd_new', function()
|
||||
eq(0, m.file_free(fp, false))
|
||||
end)
|
||||
itp('can use file descriptor returned by os_open for writing', function()
|
||||
eq(nil, luv.fs_stat(filec))
|
||||
eq(nil, uv.fs_stat(filec))
|
||||
local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384)
|
||||
local err, fp = file_open_fd_new(fd, m.kFileWriteOnly)
|
||||
eq(0, err)
|
||||
eq(4, file_write(fp, 'test'))
|
||||
eq(0, m.file_free(fp, false))
|
||||
eq(4, luv.fs_stat(filec).size)
|
||||
eq(4, uv.fs_stat(filec).size)
|
||||
eq('test', io.open(filec):read('*a'))
|
||||
end)
|
||||
end)
|
||||
@ -155,7 +155,7 @@ describe('file_open', function()
|
||||
itp('can create a rwx------ file with kFileCreate', function()
|
||||
local err, fp = file_open(filec, m.kFileCreate, 448)
|
||||
eq(0, err)
|
||||
local attrs = luv.fs_stat(filec)
|
||||
local attrs = uv.fs_stat(filec)
|
||||
eq(33216, attrs.mode)
|
||||
eq(0, m.file_close(fp, false))
|
||||
end)
|
||||
@ -163,7 +163,7 @@ describe('file_open', function()
|
||||
itp('can create a rw------- file with kFileCreate', function()
|
||||
local err, fp = file_open(filec, m.kFileCreate, 384)
|
||||
eq(0, err)
|
||||
local attrs = luv.fs_stat(filec)
|
||||
local attrs = uv.fs_stat(filec)
|
||||
eq(33152, attrs.mode)
|
||||
eq(0, m.file_close(fp, false))
|
||||
end)
|
||||
@ -171,7 +171,7 @@ describe('file_open', function()
|
||||
itp('can create a rwx------ file with kFileCreateOnly', function()
|
||||
local err, fp = file_open(filec, m.kFileCreateOnly, 448)
|
||||
eq(0, err)
|
||||
local attrs = luv.fs_stat(filec)
|
||||
local attrs = uv.fs_stat(filec)
|
||||
eq(33216, attrs.mode)
|
||||
eq(0, m.file_close(fp, false))
|
||||
end)
|
||||
@ -179,7 +179,7 @@ describe('file_open', function()
|
||||
itp('can create a rw------- file with kFileCreateOnly', function()
|
||||
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
||||
eq(0, err)
|
||||
local attrs = luv.fs_stat(filec)
|
||||
local attrs = uv.fs_stat(filec)
|
||||
eq(33152, attrs.mode)
|
||||
eq(0, m.file_close(fp, false))
|
||||
end)
|
||||
@ -231,7 +231,7 @@ describe('file_open', function()
|
||||
eq(0, err)
|
||||
eq(true, fp.wr)
|
||||
eq(0, m.file_close(fp, false))
|
||||
local attrs = luv.fs_stat(file1)
|
||||
local attrs = uv.fs_stat(file1)
|
||||
eq(0, attrs.size)
|
||||
end)
|
||||
|
||||
@ -240,14 +240,14 @@ describe('file_open', function()
|
||||
eq(0, err)
|
||||
eq(true, fp.wr)
|
||||
eq(0, m.file_close(fp, false))
|
||||
local attrs = luv.fs_stat(file1)
|
||||
local attrs = uv.fs_stat(file1)
|
||||
eq(4096, attrs.size)
|
||||
end)
|
||||
|
||||
itp('fails to create a file with just kFileWriteOnly', function()
|
||||
local err, _ = file_open(filec, m.kFileWriteOnly, 384)
|
||||
eq(m.UV_ENOENT, err)
|
||||
local attrs = luv.fs_stat(filec)
|
||||
local attrs = uv.fs_stat(filec)
|
||||
eq(nil, attrs)
|
||||
end)
|
||||
|
||||
@ -256,7 +256,7 @@ describe('file_open', function()
|
||||
eq(0, err)
|
||||
eq(true, fp.wr)
|
||||
eq(0, m.file_close(fp, false))
|
||||
local attrs = luv.fs_stat(file1)
|
||||
local attrs = uv.fs_stat(file1)
|
||||
eq(0, attrs.size)
|
||||
end)
|
||||
|
||||
@ -297,9 +297,9 @@ describe('file_close', function()
|
||||
eq(0, err)
|
||||
local wsize = file_write(fp, 'test')
|
||||
eq(4, wsize)
|
||||
eq(0, luv.fs_stat(filec).size)
|
||||
eq(0, uv.fs_stat(filec).size)
|
||||
eq(0, m.file_close(fp, true))
|
||||
eq(wsize, luv.fs_stat(filec).size)
|
||||
eq(wsize, uv.fs_stat(filec).size)
|
||||
end)
|
||||
end)
|
||||
|
||||
@ -309,9 +309,9 @@ describe('file_free', function()
|
||||
eq(0, err)
|
||||
local wsize = file_write(fp, 'test')
|
||||
eq(4, wsize)
|
||||
eq(0, luv.fs_stat(filec).size)
|
||||
eq(0, uv.fs_stat(filec).size)
|
||||
eq(0, m.file_free(fp, true))
|
||||
eq(wsize, luv.fs_stat(filec).size)
|
||||
eq(wsize, uv.fs_stat(filec).size)
|
||||
end)
|
||||
end)
|
||||
|
||||
@ -320,12 +320,12 @@ describe('file_fsync', function()
|
||||
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
||||
eq(0, file_fsync(fp))
|
||||
eq(0, err)
|
||||
eq(0, luv.fs_stat(filec).size)
|
||||
eq(0, uv.fs_stat(filec).size)
|
||||
local wsize = file_write(fp, 'test')
|
||||
eq(4, wsize)
|
||||
eq(0, luv.fs_stat(filec).size)
|
||||
eq(0, uv.fs_stat(filec).size)
|
||||
eq(0, file_fsync(fp))
|
||||
eq(wsize, luv.fs_stat(filec).size)
|
||||
eq(wsize, uv.fs_stat(filec).size)
|
||||
eq(0, m.file_close(fp, false))
|
||||
end)
|
||||
end)
|
||||
@ -335,12 +335,12 @@ describe('file_flush', function()
|
||||
local err, fp = file_open(filec, m.kFileCreateOnly, 384)
|
||||
eq(0, file_flush(fp))
|
||||
eq(0, err)
|
||||
eq(0, luv.fs_stat(filec).size)
|
||||
eq(0, uv.fs_stat(filec).size)
|
||||
local wsize = file_write(fp, 'test')
|
||||
eq(4, wsize)
|
||||
eq(0, luv.fs_stat(filec).size)
|
||||
eq(0, uv.fs_stat(filec).size)
|
||||
eq(0, file_flush(fp))
|
||||
eq(wsize, luv.fs_stat(filec).size)
|
||||
eq(wsize, uv.fs_stat(filec).size)
|
||||
eq(0, m.file_close(fp, false))
|
||||
end)
|
||||
end)
|
||||
@ -411,7 +411,7 @@ describe('file_write', function()
|
||||
local wr = file_write(fp, fcontents)
|
||||
eq(#fcontents, wr)
|
||||
eq(0, m.file_close(fp, false))
|
||||
eq(wr, luv.fs_stat(filec).size)
|
||||
eq(wr, uv.fs_stat(filec).size)
|
||||
eq(fcontents, io.open(filec):read('*a'))
|
||||
end)
|
||||
|
||||
@ -428,7 +428,7 @@ describe('file_write', function()
|
||||
shift = shift + size
|
||||
end
|
||||
eq(0, m.file_close(fp, false))
|
||||
eq(#fcontents, luv.fs_stat(filec).size)
|
||||
eq(#fcontents, uv.fs_stat(filec).size)
|
||||
eq(fcontents, io.open(filec):read('*a'))
|
||||
end)
|
||||
|
||||
@ -445,7 +445,7 @@ describe('file_write', function()
|
||||
shift = shift + size
|
||||
end
|
||||
eq(0, m.file_close(fp, false))
|
||||
eq(#fcontents, luv.fs_stat(filec).size)
|
||||
eq(#fcontents, uv.fs_stat(filec).size)
|
||||
eq(fcontents, io.open(filec):read('*a'))
|
||||
end)
|
||||
end)
|
||||
|
@ -1,4 +1,4 @@
|
||||
local luv = require('luv')
|
||||
local uv = vim.uv
|
||||
local bit = require('bit')
|
||||
|
||||
local helpers = require('test.unit.helpers')(after_each)
|
||||
@ -46,11 +46,11 @@ local function unset_bit(number, to_unset)
|
||||
end
|
||||
|
||||
local function assert_file_exists(filepath)
|
||||
neq(nil, luv.fs_stat(filepath))
|
||||
neq(nil, uv.fs_stat(filepath))
|
||||
end
|
||||
|
||||
local function assert_file_does_not_exist(filepath)
|
||||
eq(nil, luv.fs_stat(filepath))
|
||||
eq(nil, uv.fs_stat(filepath))
|
||||
end
|
||||
|
||||
local function os_setperm(filename, perm)
|
||||
@ -73,9 +73,9 @@ describe('fs.c', function()
|
||||
io.open('unit-test-directory/test.file', 'w'):close()
|
||||
|
||||
io.open('unit-test-directory/test_2.file', 'w'):close()
|
||||
luv.fs_symlink('test.file', 'unit-test-directory/test_link.file')
|
||||
uv.fs_symlink('test.file', 'unit-test-directory/test_link.file')
|
||||
|
||||
luv.fs_symlink('non_existing_file.file', 'unit-test-directory/test_broken_link.file')
|
||||
uv.fs_symlink('non_existing_file.file', 'unit-test-directory/test_broken_link.file')
|
||||
-- The tests are invoked with an absolute path to `busted` executable.
|
||||
absolute_executable = arg[0]
|
||||
-- Split the absolute_executable path into a directory and filename.
|
||||
@ -88,19 +88,19 @@ describe('fs.c', function()
|
||||
os.remove('unit-test-directory/test_link.file')
|
||||
os.remove('unit-test-directory/test_hlink.file')
|
||||
os.remove('unit-test-directory/test_broken_link.file')
|
||||
luv.fs_rmdir('unit-test-directory')
|
||||
uv.fs_rmdir('unit-test-directory')
|
||||
end)
|
||||
|
||||
describe('os_dirname', function()
|
||||
itp('returns OK and writes current directory to the buffer', function()
|
||||
local length = string.len(luv.cwd()) + 1
|
||||
local length = string.len(uv.cwd()) + 1
|
||||
local buf = cstr(length, '')
|
||||
eq(OK, fs.os_dirname(buf, length))
|
||||
eq(luv.cwd(), ffi.string(buf))
|
||||
eq(uv.cwd(), ffi.string(buf))
|
||||
end)
|
||||
|
||||
itp('returns FAIL if the buffer is too small', function()
|
||||
local length = string.len(luv.cwd()) + 1
|
||||
local length = string.len(uv.cwd()) + 1
|
||||
local buf = cstr(length - 1, '')
|
||||
eq(FAIL, fs.os_dirname(buf, length - 1))
|
||||
end)
|
||||
@ -201,20 +201,20 @@ describe('fs.c', function()
|
||||
end)
|
||||
|
||||
itp('returns the absolute path when given an executable relative to the current dir', function()
|
||||
local old_dir = luv.cwd()
|
||||
local old_dir = uv.cwd()
|
||||
|
||||
luv.chdir(directory)
|
||||
uv.chdir(directory)
|
||||
|
||||
-- Rely on currentdir to resolve symlinks, if any. Testing against
|
||||
-- the absolute path taken from arg[0] may result in failure where
|
||||
-- the path has a symlink in it.
|
||||
local canonical = luv.cwd() .. '/' .. executable_name
|
||||
local canonical = uv.cwd() .. '/' .. executable_name
|
||||
local expected = exe(canonical)
|
||||
local relative_executable = './' .. executable_name
|
||||
local res = exe(relative_executable)
|
||||
|
||||
-- Don't test yet; we need to chdir back first.
|
||||
luv.chdir(old_dir)
|
||||
uv.chdir(old_dir)
|
||||
eq(expected, res)
|
||||
end)
|
||||
end)
|
||||
@ -276,11 +276,11 @@ describe('fs.c', function()
|
||||
describe('os_fchown', function()
|
||||
local filename = 'unit-test-directory/test.file'
|
||||
itp('does not change owner and group if respective IDs are equal to -1', function()
|
||||
local uid = luv.fs_stat(filename).uid
|
||||
local gid = luv.fs_stat(filename).gid
|
||||
local uid = uv.fs_stat(filename).uid
|
||||
local gid = uv.fs_stat(filename).gid
|
||||
eq(0, os_fchown(filename, -1, -1))
|
||||
eq(uid, luv.fs_stat(filename).uid)
|
||||
return eq(gid, luv.fs_stat(filename).gid)
|
||||
eq(uid, uv.fs_stat(filename).uid)
|
||||
return eq(gid, uv.fs_stat(filename).gid)
|
||||
end)
|
||||
|
||||
-- Some systems may not have `id` utility.
|
||||
@ -290,7 +290,7 @@ describe('fs.c', function()
|
||||
itp(
|
||||
'owner of a file may change the group of the file to any group of which that owner is a member',
|
||||
function()
|
||||
local file_gid = luv.fs_stat(filename).gid
|
||||
local file_gid = uv.fs_stat(filename).gid
|
||||
|
||||
-- Gets ID of any group of which current user is a member except the
|
||||
-- group that owns the file.
|
||||
@ -305,7 +305,7 @@ describe('fs.c', function()
|
||||
-- In that case we can not perform this test.
|
||||
if new_gid then
|
||||
eq(0, (os_fchown(filename, -1, new_gid)))
|
||||
eq(new_gid, luv.fs_stat(filename).gid)
|
||||
eq(new_gid, uv.fs_stat(filename).gid)
|
||||
end
|
||||
end
|
||||
)
|
||||
@ -554,7 +554,7 @@ describe('fs.c', function()
|
||||
--create the file
|
||||
local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber('700', 8))
|
||||
--verify permissions
|
||||
eq(33216, luv.fs_stat(new_file).mode)
|
||||
eq(33216, uv.fs_stat(new_file).mode)
|
||||
eq(0, os_close(fd))
|
||||
end)
|
||||
|
||||
@ -563,7 +563,7 @@ describe('fs.c', function()
|
||||
--create the file
|
||||
local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber('600', 8))
|
||||
--verify permissions
|
||||
eq(33152, luv.fs_stat(new_file).mode)
|
||||
eq(33152, uv.fs_stat(new_file).mode)
|
||||
eq(0, os_close(fd))
|
||||
end)
|
||||
|
||||
@ -793,7 +793,7 @@ describe('fs.c', function()
|
||||
eq(false, (os_isdir('unit-test-directory/new-dir')))
|
||||
eq(0, (os_mkdir('unit-test-directory/new-dir', mode)))
|
||||
eq(true, (os_isdir('unit-test-directory/new-dir')))
|
||||
luv.fs_rmdir('unit-test-directory/new-dir')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir')
|
||||
end)
|
||||
end)
|
||||
|
||||
@ -831,7 +831,7 @@ describe('fs.c', function()
|
||||
eq(nil, failed_dir)
|
||||
ok(endswith(created_dir, 'unit-test-directory/new-dir-recurse'))
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
end)
|
||||
|
||||
@ -843,7 +843,7 @@ describe('fs.c', function()
|
||||
eq(nil, failed_dir)
|
||||
ok(endswith(created_dir, 'unit-test-directory/new-dir-recurse'))
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
end)
|
||||
|
||||
@ -855,7 +855,7 @@ describe('fs.c', function()
|
||||
eq(nil, failed_dir)
|
||||
ok(endswith(created_dir, 'unit-test-directory/new-dir-recurse'))
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
end)
|
||||
|
||||
@ -870,10 +870,10 @@ describe('fs.c', function()
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1'))
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1/2'))
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse/1/2/3'))
|
||||
luv.fs_rmdir('unit-test-directory/new-dir-recurse/1/2/3')
|
||||
luv.fs_rmdir('unit-test-directory/new-dir-recurse/1/2')
|
||||
luv.fs_rmdir('unit-test-directory/new-dir-recurse/1')
|
||||
luv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir-recurse/1/2/3')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir-recurse/1/2')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir-recurse/1')
|
||||
uv.fs_rmdir('unit-test-directory/new-dir-recurse')
|
||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
end)
|
||||
end)
|
||||
@ -1038,7 +1038,7 @@ describe('fs.c', function()
|
||||
file:write('some bytes to get filesize != 0')
|
||||
file:flush()
|
||||
file:close()
|
||||
local size = luv.fs_stat(path).size
|
||||
local size = uv.fs_stat(path).size
|
||||
local info = file_info_new()
|
||||
assert.is_true(fs.os_fileinfo(path, info))
|
||||
eq(size, fs.os_fileinfo_size(info))
|
||||
@ -1052,7 +1052,7 @@ describe('fs.c', function()
|
||||
local info = file_info_new()
|
||||
assert.is_true(fs.os_fileinfo(path, info))
|
||||
eq(1, fs.os_fileinfo_hardlinks(info))
|
||||
luv.fs_link(path, path_link)
|
||||
uv.fs_link(path, path_link)
|
||||
assert.is_true(fs.os_fileinfo(path, info))
|
||||
eq(2, fs.os_fileinfo_hardlinks(info))
|
||||
end)
|
||||
@ -1061,7 +1061,7 @@ describe('fs.c', function()
|
||||
describe('os_fileinfo_blocksize', function()
|
||||
itp('returns the correct blocksize of a file', function()
|
||||
local path = 'unit-test-directory/test.file'
|
||||
local blksize = luv.fs_stat(path).blksize
|
||||
local blksize = uv.fs_stat(path).blksize
|
||||
local info = file_info_new()
|
||||
assert.is_true(fs.os_fileinfo(path, info))
|
||||
if blksize then
|
||||
|
@ -1,4 +1,4 @@
|
||||
local luv = require('luv')
|
||||
local uv = vim.uv
|
||||
local helpers = require('test.unit.helpers')(after_each)
|
||||
local itp = helpers.gen_itp(it)
|
||||
|
||||
@ -27,7 +27,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
teardown(function()
|
||||
luv.fs_rmdir('unit-test-directory')
|
||||
uv.fs_rmdir('unit-test-directory')
|
||||
end)
|
||||
|
||||
local function path_full_dir_name(directory, buf, len)
|
||||
@ -37,34 +37,34 @@ describe('path.c', function()
|
||||
|
||||
before_each(function()
|
||||
-- Create empty string buffer which will contain the resulting path.
|
||||
length = string.len(luv.cwd()) + 22
|
||||
length = string.len(uv.cwd()) + 22
|
||||
buffer = cstr(length, '')
|
||||
end)
|
||||
|
||||
itp('returns the absolute directory name of a given relative one', function()
|
||||
local result = path_full_dir_name('..', buffer, length)
|
||||
eq(OK, result)
|
||||
local old_dir = luv.cwd()
|
||||
luv.chdir('..')
|
||||
local expected = luv.cwd()
|
||||
luv.chdir(old_dir)
|
||||
local old_dir = uv.cwd()
|
||||
uv.chdir('..')
|
||||
local expected = uv.cwd()
|
||||
uv.chdir(old_dir)
|
||||
eq(expected, (ffi.string(buffer)))
|
||||
end)
|
||||
|
||||
itp('returns the current directory name if the given string is empty', function()
|
||||
eq(OK, (path_full_dir_name('', buffer, length)))
|
||||
eq(luv.cwd(), (ffi.string(buffer)))
|
||||
eq(uv.cwd(), (ffi.string(buffer)))
|
||||
end)
|
||||
|
||||
itp('works with a normal relative dir', function()
|
||||
local result = path_full_dir_name('unit-test-directory', buffer, length)
|
||||
eq(luv.cwd() .. '/unit-test-directory', (ffi.string(buffer)))
|
||||
eq(uv.cwd() .. '/unit-test-directory', (ffi.string(buffer)))
|
||||
eq(OK, result)
|
||||
end)
|
||||
|
||||
itp('works with a non-existing relative dir', function()
|
||||
local result = path_full_dir_name('does-not-exist', buffer, length)
|
||||
eq(luv.cwd() .. '/does-not-exist', (ffi.string(buffer)))
|
||||
eq(uv.cwd() .. '/does-not-exist', (ffi.string(buffer)))
|
||||
eq(OK, result)
|
||||
end)
|
||||
|
||||
@ -270,27 +270,27 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
describe('path_try_shorten_fname', function()
|
||||
local cwd = luv.cwd()
|
||||
local cwd = uv.cwd()
|
||||
|
||||
before_each(function()
|
||||
mkdir('ut_directory')
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
luv.chdir(cwd)
|
||||
luv.fs_rmdir('ut_directory')
|
||||
uv.chdir(cwd)
|
||||
uv.fs_rmdir('ut_directory')
|
||||
end)
|
||||
|
||||
describe('path_try_shorten_fname', function()
|
||||
itp('returns shortened path if possible', function()
|
||||
luv.chdir('ut_directory')
|
||||
local full = to_cstr(luv.cwd() .. '/subdir/file.txt')
|
||||
uv.chdir('ut_directory')
|
||||
local full = to_cstr(uv.cwd() .. '/subdir/file.txt')
|
||||
eq('subdir/file.txt', (ffi.string(cimp.path_try_shorten_fname(full))))
|
||||
end)
|
||||
|
||||
itp('returns `full_path` if a shorter version is not possible', function()
|
||||
local old = luv.cwd()
|
||||
luv.chdir('ut_directory')
|
||||
local old = uv.cwd()
|
||||
uv.chdir('ut_directory')
|
||||
local full = old .. '/subdir/file.txt'
|
||||
eq(full, (ffi.string(cimp.path_try_shorten_fname(to_cstr(full)))))
|
||||
end)
|
||||
@ -302,7 +302,7 @@ describe('path_try_shorten_fname', function()
|
||||
end)
|
||||
|
||||
describe('path.c path_guess_exepath', function()
|
||||
local cwd = luv.cwd()
|
||||
local cwd = uv.cwd()
|
||||
|
||||
for _, name in ipairs({ './nvim', '.nvim', 'foo/nvim' }) do
|
||||
itp('"' .. name .. '" returns name catenated with CWD', function()
|
||||
@ -370,7 +370,7 @@ describe('path.c', function()
|
||||
|
||||
teardown(function()
|
||||
os.remove('unit-test-directory/test.file')
|
||||
luv.fs_rmdir('unit-test-directory')
|
||||
uv.fs_rmdir('unit-test-directory')
|
||||
end)
|
||||
|
||||
describe('vim_FullName', function()
|
||||
@ -422,7 +422,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
itp('concatenates filename if it does not contain a slash', function()
|
||||
local expected = luv.cwd() .. '/test.file'
|
||||
local expected = uv.cwd() .. '/test.file'
|
||||
local filename = 'test.file'
|
||||
local buflen = get_buf_len(expected, filename)
|
||||
local do_expand = 1
|
||||
@ -432,7 +432,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
itp('concatenates directory name if it does not contain a slash', function()
|
||||
local expected = luv.cwd() .. '/..'
|
||||
local expected = uv.cwd() .. '/..'
|
||||
local filename = '..'
|
||||
local buflen = get_buf_len(expected, filename)
|
||||
local do_expand = 1
|
||||
@ -444,10 +444,10 @@ describe('path.c', function()
|
||||
itp(
|
||||
'enters given directory (instead of just concatenating the strings) if possible and if path contains a slash',
|
||||
function()
|
||||
local old_dir = luv.cwd()
|
||||
luv.chdir('..')
|
||||
local expected = luv.cwd() .. '/test.file'
|
||||
luv.chdir(old_dir)
|
||||
local old_dir = uv.cwd()
|
||||
uv.chdir('..')
|
||||
local expected = uv.cwd() .. '/test.file'
|
||||
uv.chdir(old_dir)
|
||||
local filename = '../test.file'
|
||||
local buflen = get_buf_len(expected, filename)
|
||||
local do_expand = 1
|
||||
@ -477,7 +477,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
itp('works with some "normal" relative path with directories', function()
|
||||
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||
local expected = uv.cwd() .. '/unit-test-directory/test.file'
|
||||
local filename = 'unit-test-directory/test.file'
|
||||
local buflen = get_buf_len(expected, filename)
|
||||
local do_expand = 1
|
||||
@ -487,7 +487,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
itp('does not modify the given filename', function()
|
||||
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||
local expected = uv.cwd() .. '/unit-test-directory/test.file'
|
||||
local filename = to_cstr('unit-test-directory/test.file')
|
||||
local buflen = string.len(expected) + 1
|
||||
local buf = cstr(buflen, '')
|
||||
@ -510,7 +510,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
itp('does not remove trailing slash from non-existing relative directory #20847', function()
|
||||
local expected = luv.cwd() .. '/non_existing_dir/'
|
||||
local expected = uv.cwd() .. '/non_existing_dir/'
|
||||
local filename = 'non_existing_dir/'
|
||||
local buflen = get_buf_len(expected, filename)
|
||||
local do_expand = 1
|
||||
@ -520,7 +520,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
itp('expands "./" to the current directory #7117', function()
|
||||
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||
local expected = uv.cwd() .. '/unit-test-directory/test.file'
|
||||
local filename = './unit-test-directory/test.file'
|
||||
local buflen = get_buf_len(expected, filename)
|
||||
local do_expand = 1
|
||||
@ -530,7 +530,7 @@ describe('path.c', function()
|
||||
end)
|
||||
|
||||
itp('collapses "foo/../foo" to "foo" #7117', function()
|
||||
local expected = luv.cwd() .. '/unit-test-directory/test.file'
|
||||
local expected = uv.cwd() .. '/unit-test-directory/test.file'
|
||||
local filename = 'unit-test-directory/../unit-test-directory/test.file'
|
||||
local buflen = get_buf_len(expected, filename)
|
||||
local do_expand = 1
|
||||
@ -551,7 +551,7 @@ describe('path.c', function()
|
||||
mkdir('CamelCase')
|
||||
end)
|
||||
after_each(function()
|
||||
luv.fs_rmdir('CamelCase')
|
||||
uv.fs_rmdir('CamelCase')
|
||||
end)
|
||||
|
||||
if ffi.os == 'Windows' or ffi.os == 'OSX' then
|
||||
|
Loading…
Reference in New Issue
Block a user