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