diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-04-04 21:59:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 21:59:06 +0200 |
commit | 743860de40502227b3f0ed64317eb937d24d4a36 (patch) | |
tree | f76386bbbc980af8d2d7fc0ddec061a52c85556d /test/functional | |
parent | b1de4820b7b1a527f4d0cf9a20192d92bea1d9c4 (diff) | |
download | rneovim-743860de40502227b3f0ed64317eb937d24d4a36.tar.gz rneovim-743860de40502227b3f0ed64317eb937d24d4a36.tar.bz2 rneovim-743860de40502227b3f0ed64317eb937d24d4a36.zip |
test: replace lfs with luv and vim.fs
test: replace lfs with luv
luv already pretty much does everything lfs does, so this duplication
of dependencies isn't needed.
Diffstat (limited to 'test/functional')
30 files changed, 118 insertions, 117 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index de0d82119c..ab26425425 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local lfs = require('lfs') local luv = require('luv') local fmt = string.format @@ -4193,7 +4192,7 @@ describe('API', function() vim.api.nvim_echo({{ opts.fargs[1] }}, false, {}) end, { nargs = 1 }) ]]) - eq(lfs.currentdir(), + eq(luv.cwd(), meths.cmd({ cmd = "Foo", args = { '%:p:h' }, magic = { file = true } }, { output = true })) end) diff --git a/test/functional/autocmd/dirchanged_spec.lua b/test/functional/autocmd/dirchanged_spec.lua index 828cffa460..20aa07d058 100644 --- a/test/functional/autocmd/dirchanged_spec.lua +++ b/test/functional/autocmd/dirchanged_spec.lua @@ -1,4 +1,4 @@ -local lfs = require('lfs') +local luv = require('luv') local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear @@ -9,7 +9,7 @@ local request = helpers.request local is_os = helpers.is_os describe('autocmd DirChanged and DirChangedPre', function() - local curdir = string.gsub(lfs.currentdir(), '\\', '/') + local curdir = string.gsub(luv.cwd(), '\\', '/') local dirs = { curdir .. '/Xtest-functional-autocmd-dirchanged.dir1', curdir .. '/Xtest-functional-autocmd-dirchanged.dir2', diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua index d7a87e17ed..33e4d88c7b 100644 --- a/test/functional/autocmd/focus_spec.lua +++ b/test/functional/autocmd/focus_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') -local lfs = require('lfs') +local luv = require('luv') local clear = helpers.clear local nvim_prog = helpers.nvim_prog local feed_command = helpers.feed_command @@ -32,7 +32,8 @@ describe('autoread TUI FocusGained/FocusLost', function() ]] helpers.write_file(path, '') - lfs.touch(path, os.time() - 10) + local atime = os.time() - 10 + luv.fs_utime(path, atime, atime) screen:expect{grid=[[ {1: } | diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index 153b53dce2..4236a4ff47 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -1,4 +1,4 @@ -local lfs = require('lfs') +local luv = require('luv') local helpers = require('test.functional.helpers')(after_each) local assert_log = helpers.assert_log @@ -142,7 +142,7 @@ describe('fileio', function() local backup_file_name = link_file_name .. '~' write_file('Xtest_startup_file1', initial_content, false) - lfs.link('Xtest_startup_file1', link_file_name, true) + luv.fs_symlink('Xtest_startup_file1', link_file_name) command('set backup') command('set backupcopy=yes') command('edit ' .. link_file_name) @@ -166,7 +166,7 @@ describe('fileio', function() local backup_file_name = backup_dir .. sep .. link_file_name .. '~' write_file('Xtest_startup_file1', initial_content, false) - lfs.link('Xtest_startup_file1', link_file_name, true) + luv.fs_symlink('Xtest_startup_file1', link_file_name) mkdir(backup_dir) command('set backup') command('set backupcopy=yes') diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua index ab11e14a67..efab40dd11 100644 --- a/test/functional/core/main_spec.lua +++ b/test/functional/core/main_spec.lua @@ -1,4 +1,4 @@ -local lfs = require('lfs') +local luv = require('luv') local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') @@ -28,18 +28,18 @@ describe('Command-line option', function() os.remove(dollar_fname) end) it('treats - as stdin', function() - eq(nil, lfs.attributes(fname)) + eq(nil, luv.fs_stat(fname)) funcs.system( {nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless', '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix', '-s', '-', fname}, {':call setline(1, "42")', ':wqall!', ''}) eq(0, eval('v:shell_error')) - local attrs = lfs.attributes(fname) + local attrs = luv.fs_stat(fname) eq(#('42\n'), attrs.size) end) it('does not expand $VAR', function() - eq(nil, lfs.attributes(fname)) + eq(nil, luv.fs_stat(fname)) eq(true, not not dollar_fname:find('%$%w+')) write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n') funcs.system( @@ -47,7 +47,7 @@ describe('Command-line option', function() '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix', '-s', dollar_fname, fname}) eq(0, eval('v:shell_error')) - local attrs = lfs.attributes(fname) + local attrs = luv.fs_stat(fname) eq(#('100500\n'), attrs.size) end) it('does not crash after reading from stdin in non-headless mode', function() @@ -121,7 +121,7 @@ describe('Command-line option', function() '--cmd', 'language C', '-s', fname, '-s', dollar_fname, fname_2})) eq(2, eval('v:shell_error')) - eq(nil, lfs.attributes(fname_2)) + eq(nil, luv.fs_stat(fname_2)) end) end) end) diff --git a/test/functional/core/spellfile_spec.lua b/test/functional/core/spellfile_spec.lua index afd2c1bce4..378899eece 100644 --- a/test/functional/core/spellfile_spec.lua +++ b/test/functional/core/spellfile_spec.lua @@ -1,5 +1,4 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') local eq = helpers.eq local clear = helpers.clear @@ -7,6 +6,7 @@ local meths = helpers.meths local exc_exec = helpers.exc_exec local rmdir = helpers.rmdir local write_file = helpers.write_file +local mkdir = helpers.mkdir local testdir = 'Xtest-functional-spell-spellfile.d' @@ -14,8 +14,8 @@ describe('spellfile', function() before_each(function() clear() rmdir(testdir) - lfs.mkdir(testdir) - lfs.mkdir(testdir .. '/spell') + mkdir(testdir) + mkdir(testdir .. '/spell') end) after_each(function() rmdir(testdir) diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index 5ed71651c7..b6a3713158 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -1,6 +1,6 @@ -- Specs for :cd, :tcd, :lcd and getcwd() -local lfs = require('lfs') +local luv = require('luv') local helpers = require('test.functional.helpers')(after_each) local eq = helpers.eq @@ -11,6 +11,7 @@ local exc_exec = helpers.exc_exec local pathsep = helpers.get_pathsep() local skip = helpers.skip local is_os = helpers.is_os +local mkdir = helpers.mkdir -- These directories will be created for testing local directories = { @@ -36,14 +37,14 @@ for _, cmd in ipairs {'cd', 'chdir'} do before_each(function() clear() for _, d in pairs(directories) do - lfs.mkdir(d) + mkdir(d) end directories.start = cwd() end) after_each(function() for _, d in pairs(directories) do - lfs.rmdir(d) + luv.fs_rmdir(d) end end) @@ -273,7 +274,7 @@ end describe("getcwd()", function () before_each(function() clear() - lfs.mkdir(directories.global) + mkdir(directories.global) end) after_each(function() diff --git a/test/functional/ex_cmds/file_spec.lua b/test/functional/ex_cmds/file_spec.lua index 771c283134..131661828e 100644 --- a/test/functional/ex_cmds/file_spec.lua +++ b/test/functional/ex_cmds/file_spec.lua @@ -1,17 +1,18 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') local clear = helpers.clear local command = helpers.command local eq = helpers.eq local funcs = helpers.funcs local rmdir = helpers.rmdir +local mkdir = helpers.mkdir describe(':file', function() - local swapdir = lfs.currentdir()..'/Xtest-file_spec' + local swapdir = luv.cwd()..'/Xtest-file_spec' before_each(function() clear() rmdir(swapdir) - lfs.mkdir(swapdir) + mkdir(swapdir) end) after_each(function() command('%bwipeout!') diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 0a1cdd93aa..d70ccb5b39 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -1,4 +1,3 @@ -local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') @@ -15,6 +14,7 @@ local sleep = helpers.sleep local meths = helpers.meths local skip = helpers.skip local is_os = helpers.is_os +local mkdir = helpers.mkdir local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec' @@ -26,7 +26,7 @@ describe(':mksession', function() before_each(function() clear() - lfs.mkdir(tab_dir) + mkdir(tab_dir) end) after_each(function() diff --git a/test/functional/ex_cmds/mkview_spec.lua b/test/functional/ex_cmds/mkview_spec.lua index fef8065b2e..f71b826210 100644 --- a/test/functional/ex_cmds/mkview_spec.lua +++ b/test/functional/ex_cmds/mkview_spec.lua @@ -1,4 +1,3 @@ -local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear @@ -7,6 +6,7 @@ local get_pathsep = helpers.get_pathsep local eq = helpers.eq local funcs = helpers.funcs local rmdir = helpers.rmdir +local mkdir = helpers.mkdir local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec' @@ -17,8 +17,8 @@ describe(':mkview', function() before_each(function() clear() - lfs.mkdir(view_dir) - lfs.mkdir(local_dir) + mkdir(view_dir) + mkdir(local_dir) end) after_each(function() diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua index bf045a4d1d..249373a9c4 100644 --- a/test/functional/ex_cmds/profile_spec.lua +++ b/test/functional/ex_cmds/profile_spec.lua @@ -1,5 +1,5 @@ require('os') -local lfs = require('lfs') +local luv = require('luv') local helpers = require('test.functional.helpers')(after_each) local eval = helpers.eval @@ -12,18 +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 lfs.attributes(tempfile, 'uid') then +if luv.fs_stat(tempfile).uid then os.remove(tempfile) end local function assert_file_exists(filepath) - -- Use 2-argument lfs.attributes() so no extra table gets created. - -- We don't really care for the uid. - neq(nil, lfs.attributes(filepath, 'uid')) + neq(nil, luv.fs_stat(filepath).uid) end local function assert_file_exists_not(filepath) - eq(nil, lfs.attributes(filepath, 'uid')) + eq(nil, luv.fs_stat(filepath)) end describe(':profile', function() @@ -31,7 +29,7 @@ describe(':profile', function() after_each(function() helpers.expect_exit(command, 'qall!') - if lfs.attributes(tempfile, 'uid') ~= nil then + if luv.fs_stat(tempfile).uid ~= nil then os.remove(tempfile) end end) diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index ad59025d47..639bc6c94e 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -1,6 +1,5 @@ local Screen = require('test.functional.ui.screen') local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') local luv = require('luv') local eq, eval, expect, exec = helpers.eq, helpers.eval, helpers.expect, helpers.exec @@ -21,6 +20,7 @@ local spawn = helpers.spawn local nvim_async = helpers.nvim_async local expect_msg_seq = helpers.expect_msg_seq local pcall_err = helpers.pcall_err +local mkdir = helpers.mkdir describe(':recover', function() before_each(clear) @@ -39,7 +39,7 @@ describe(':recover', function() end) describe("preserve and (R)ecover with custom 'directory'", function() - local swapdir = lfs.currentdir()..'/Xtest_recover_dir' + local swapdir = luv.cwd()..'/Xtest_recover_dir' local testfile = 'Xtest_recover_file1' -- Put swapdir at the start of the 'directory' list. #1836 -- Note: `set swapfile` *must* go after `set directory`: otherwise it may @@ -54,7 +54,7 @@ describe("preserve and (R)ecover with custom 'directory'", function() nvim1 = spawn(new_argv()) set_session(nvim1) rmdir(swapdir) - lfs.mkdir(swapdir) + mkdir(swapdir) end) after_each(function() command('%bwipeout!') @@ -126,7 +126,7 @@ describe("preserve and (R)ecover with custom 'directory'", function() end) describe('swapfile detection', function() - local swapdir = lfs.currentdir()..'/Xtest_swapdialog_dir' + local swapdir = luv.cwd()..'/Xtest_swapdialog_dir' local nvim0 -- Put swapdir at the start of the 'directory' list. #1836 -- Note: `set swapfile` *must* go after `set directory`: otherwise it may @@ -139,7 +139,7 @@ describe('swapfile detection', function() nvim0 = spawn(new_argv()) set_session(nvim0) rmdir(swapdir) - lfs.mkdir(swapdir) + mkdir(swapdir) end) after_each(function() set_session(nvim0) @@ -361,7 +361,8 @@ describe('swapfile detection', function() ]]) -- pretend that the swapfile was created before boot - lfs.touch(swname, os.time() - luv.uptime() - 10) + local atime = os.time() - luv.uptime() - 10 + luv.fs_utime(swname, atime, atime) feed(':edit Xswaptest<CR>') screen:expect({any = table.concat({ diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index 1ccd27875e..126646f21a 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -1,5 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +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 @@ -153,7 +153,7 @@ describe(':write', function() end write_file(fname_bak, 'TTYX') skip(is_os('win'), [[FIXME: exc_exec('write!') outputs 0 in Windows]]) - lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true) + luv.fs_symlink(fname_bak .. ('/xxxxx'):rep(20), fname) eq('Vim(write):E166: Can\'t open linked file for writing', pcall_err(command, 'write!')) end) diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua index 861a977ea6..7525343891 100644 --- a/test/functional/ex_cmds/wviminfo_spec.lua +++ b/test/functional/ex_cmds/wviminfo_spec.lua @@ -1,5 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') local clear = helpers.clear local command, eq, neq, write_file = helpers.command, helpers.eq, helpers.neq, helpers.write_file @@ -21,10 +21,10 @@ describe(':wshada', function() it('creates a shada file', function() -- file should _not_ exist - eq(nil, lfs.attributes(shada_file)) + eq(nil, luv.fs_stat(shada_file)) command('wsh! '..shada_file) -- file _should_ exist - neq(nil, lfs.attributes(shada_file)) + neq(nil, luv.fs_stat(shada_file)) end) it('overwrites existing files', function() @@ -35,7 +35,7 @@ describe(':wshada', function() -- sanity check eq(text, read_file(shada_file)) - neq(nil, lfs.attributes(shada_file)) + neq(nil, luv.fs_stat(shada_file)) command('wsh! '..shada_file) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 188c196eb3..2e373467d0 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -1,5 +1,4 @@ local luv = require('luv') -local lfs = require('lfs') local global_helpers = require('test.helpers') local Session = require('test.client.session') @@ -20,10 +19,9 @@ local tbl_contains = global_helpers.tbl_contains local fail = global_helpers.fail local module = { - mkdir = lfs.mkdir, } -local start_dir = lfs.currentdir() +local start_dir = luv.cwd() local runtime_set = 'set runtimepath^=./build/lib/nvim/' module.nvim_prog = ( os.getenv('NVIM_PRG') @@ -730,21 +728,17 @@ function module.assert_visible(bufnr, visible) end local function do_rmdir(path) - local mode, errmsg, errcode = lfs.attributes(path, 'mode') - if mode == nil then - if errcode == 2 then - -- "No such file or directory", don't complain. - return - end - error(string.format('rmdir: %s (%d)', errmsg, errcode)) + local stat = luv.fs_stat(path) + if stat == nil then + return end - if mode ~= 'directory' then + if stat.type ~= 'directory' then error(string.format('rmdir: not a directory: %s', path)) end - for file in lfs.dir(path) do + for file in vim.fs.dir(path) do if file ~= '.' and file ~= '..' then local abspath = path..'/'..file - if lfs.attributes(abspath, 'mode') == 'directory' then + if global_helpers.isdir(abspath) then do_rmdir(abspath) -- recurse else local ret, err = os.remove(abspath) @@ -764,9 +758,9 @@ local function do_rmdir(path) end end end - local ret, err = lfs.rmdir(path) + local ret, err = luv.fs_rmdir(path) if not ret then - error('lfs.rmdir('..path..'): '..err) + error('luv.fs_rmdir('..path..'): '..err) end end diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua index 7ae851467f..5b6d030567 100644 --- a/test/functional/legacy/011_autocommands_spec.lua +++ b/test/functional/legacy/011_autocommands_spec.lua @@ -13,7 +13,7 @@ -- being modified outside of Vim (noticed on Solaris). local helpers= require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') local clear, feed_command, expect, eq, neq, dedent, write_file, feed = helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq, helpers.dedent, helpers.write_file, helpers.feed @@ -31,8 +31,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, lfs.attributes(name..'.gz')) - eq(nil, lfs.attributes(name)) + neq(nil, luv.fs_stat(name..'.gz')) + eq(nil, luv.fs_stat(name)) end describe('file reading, writing and bufnew and filter autocommands', function() diff --git a/test/functional/legacy/012_directory_spec.lua b/test/functional/legacy/012_directory_spec.lua index dd207ca0b4..050e3855fe 100644 --- a/test/functional/legacy/012_directory_spec.lua +++ b/test/functional/legacy/012_directory_spec.lua @@ -4,7 +4,7 @@ -- - "dir", in directory relative to current dir local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') local eq = helpers.eq local neq = helpers.neq @@ -17,10 +17,11 @@ local command = helpers.command local write_file = helpers.write_file local curbufmeths = helpers.curbufmeths local expect_exit = helpers.expect_exit +local mkdir = helpers.mkdir local function ls_dir_sorted(dirname) local files = {} - for f in lfs.dir(dirname) do + for f in vim.fs.dir(dirname) do if f ~= "." and f~= ".." then table.insert(files, f) end @@ -38,8 +39,8 @@ describe("'directory' option", function() end of testfile ]] write_file('Xtest1', text) - lfs.mkdir('Xtest.je') - lfs.mkdir('Xtest2') + mkdir('Xtest.je') + mkdir('Xtest2') write_file('Xtest2/Xtest3', text) clear() end) @@ -62,21 +63,21 @@ describe("'directory' option", function() meths.set_option('directory', '.') -- sanity check: files should not exist yet. - eq(nil, lfs.attributes('.Xtest1.swp')) + eq(nil, luv.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, lfs.attributes('.Xtest1.swp')) + neq(nil, luv.fs_stat('.Xtest1.swp')) meths.set_option('directory', './Xtest2,.') command('edit Xtest1') poke_eventloop() -- swapfile should no longer exist in CWD. - eq(nil, lfs.attributes('.Xtest1.swp')) + eq(nil, luv.fs_stat('.Xtest1.swp')) eq({ "Xtest1.swp", "Xtest3" }, ls_dir_sorted("Xtest2")) diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua index 445d742c1f..06d8b276d7 100644 --- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua +++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua @@ -1,7 +1,7 @@ -- Tests for storing global variables in the .shada file local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +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 @@ -39,7 +39,7 @@ describe('storing global variables in ShaDa files', function() poke_eventloop() -- Assert that the shada file exists. - neq(nil, lfs.attributes(tempname)) + neq(nil, luv.fs_stat(tempname)) command('unlet MY_GLOBAL_DICT') command('unlet MY_GLOBAL_LIST') -- Assert that the variables where deleted. diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua index 13cb6cd287..5da54b4850 100644 --- a/test/functional/legacy/autochdir_spec.lua +++ b/test/functional/legacy/autochdir_spec.lua @@ -1,8 +1,8 @@ -local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) local clear, eq, matches = helpers.clear, helpers.eq, helpers.matches local eval, command, call, meths = helpers.eval, helpers.command, helpers.call, helpers.meths local source, exec_capture = helpers.source, helpers.exec_capture +local mkdir = helpers.mkdir local function expected_empty() eq({}, meths.get_vvar('errors')) @@ -12,7 +12,7 @@ describe('autochdir behavior', function() local dir = 'Xtest_functional_legacy_autochdir' before_each(function() - lfs.mkdir(dir) + mkdir(dir) clear() command('set shellslash') end) diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 2cd3123dcd..04f4f89472 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -1,6 +1,6 @@ -- Test suite for testing interactions with API bindings local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') local command = helpers.command local meths = helpers.meths @@ -754,7 +754,8 @@ describe('lua: nvim_buf_attach on_bytes', function() write_file("Xtest-reload", dedent [[ old line 1 old line 2]]) - lfs.touch("Xtest-reload", os.time() - 10) + local atime = os.time() - 10 + luv.fs_utime("Xtest-reload", atime, atime) command "e Xtest-reload" command "set autoread" diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index da60b5c13b..aeb2e5d9a6 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -1,5 +1,4 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') local clear = helpers.clear local exec_lua = helpers.exec_lua @@ -11,6 +10,7 @@ local test_build_dir = helpers.test_build_dir local test_source_path = helpers.test_source_path local nvim_prog = helpers.nvim_prog local is_os = helpers.is_os +local mkdir = helpers.mkdir local nvim_prog_basename = is_os('win') and 'nvim.exe' or 'nvim' @@ -133,10 +133,10 @@ describe('vim.fs', function() describe('dir()', function() before_each(function() - lfs.mkdir('testd') - lfs.mkdir('testd/a') - lfs.mkdir('testd/a/b') - lfs.mkdir('testd/a/b/c') + mkdir('testd') + mkdir('testd/a') + mkdir('testd/a/b') + mkdir('testd/a/b/c') end) after_each(function() diff --git a/test/functional/lua/watch_spec.lua b/test/functional/lua/watch_spec.lua index 554480c2b3..bbcfd27cde 100644 --- a/test/functional/lua/watch_spec.lua +++ b/test/functional/lua/watch_spec.lua @@ -3,7 +3,7 @@ local eq = helpers.eq local exec_lua = helpers.exec_lua local clear = helpers.clear local is_os = helpers.is_os -local lfs = require('lfs') +local mkdir = helpers.mkdir describe('vim._watch', function() before_each(function() @@ -14,7 +14,7 @@ describe('vim._watch', function() it('detects file changes', function() local root_dir = helpers.tmpname() os.remove(root_dir) - lfs.mkdir(root_dir) + mkdir(root_dir) local result = exec_lua( [[ @@ -102,7 +102,7 @@ describe('vim._watch', function() it('detects file changes', function() local root_dir = helpers.tmpname() os.remove(root_dir) - lfs.mkdir(root_dir) + mkdir(root_dir) local result = exec_lua( [[ diff --git a/test/functional/options/autochdir_spec.lua b/test/functional/options/autochdir_spec.lua index 0b6fe9533c..c75a98f35b 100644 --- a/test/functional/options/autochdir_spec.lua +++ b/test/functional/options/autochdir_spec.lua @@ -1,9 +1,10 @@ -local lfs = require('lfs') +local luv = require('luv') local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local eq = helpers.eq local funcs = helpers.funcs local command = helpers.command +local mkdir = helpers.mkdir describe("'autochdir'", function() it('given on the shell gets processed properly', function() @@ -20,11 +21,11 @@ describe("'autochdir'", function() end) it('is not overwritten by getwinvar() call #17609',function() - local curdir = string.gsub(lfs.currentdir(), '\\', '/') + local curdir = string.gsub(luv.cwd(), '\\', '/') local dir_a = curdir..'/Xtest-functional-options-autochdir.dir_a' local dir_b = curdir..'/Xtest-functional-options-autochdir.dir_b' - lfs.mkdir(dir_a) - lfs.mkdir(dir_b) + mkdir(dir_a) + mkdir(dir_b) clear() command('set shellslash') command('set autochdir') diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 7d287d38fa..da05b09593 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local lsp_helpers = require('test.functional.plugin.lsp.helpers') -local lfs = require('lfs') local assert_log = helpers.assert_log local buf_lines = helpers.buf_lines @@ -24,6 +23,7 @@ local is_ci = helpers.is_ci local meths = helpers.meths local is_os = helpers.is_os local skip = helpers.skip +local mkdir = helpers.mkdir local clear_notrace = lsp_helpers.clear_notrace local create_server_definition = lsp_helpers.create_server_definition @@ -3768,7 +3768,7 @@ describe('LSP', function() it('sends notifications when files change', function() local root_dir = helpers.tmpname() os.remove(root_dir) - lfs.mkdir(root_dir) + mkdir(root_dir) exec_lua(create_server_definition) local result = exec_lua([[ diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua index 24bd363e95..cc21d08620 100644 --- a/test/functional/shada/shada_spec.lua +++ b/test/functional/shada/shada_spec.lua @@ -8,7 +8,7 @@ local write_file, spawn, set_session, nvim_prog, exc_exec = local is_os = helpers.is_os local skip = helpers.skip -local lfs = require('lfs') +local luv = require('luv') local paths = require('test.cmakeconfig.paths') local mpack = require('mpack') @@ -29,7 +29,7 @@ describe('ShaDa support code', function() after_each(function() clear() clean() - lfs.rmdir(dirname) + luv.fs_rmdir(dirname) end) it('preserves `s` item size limit with unknown entries', function() @@ -81,7 +81,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, lfs.attributes(shada_fname .. '.tmp.a')) + eq(nil, luv.fs_stat(shada_fname .. '.tmp.a')) end) it('leaves .tmp.b in-place when there is error in original ShaDa and it has .tmp.a', function() @@ -251,8 +251,8 @@ describe('ShaDa support code', function() local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed', '--headless', '--cmd', 'qall'}, true) session:close() - eq(nil, lfs.attributes('NONE')) - eq(nil, lfs.attributes('NONE.tmp.a')) + eq(nil, luv.fs_stat('NONE')) + eq(nil, luv.fs_stat('NONE.tmp.a')) end) it('does not read NONE file', function() diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index c032ac3030..dc591c3e0d 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local lfs = require('lfs') +local luv = require('luv') local neq, eq, command = helpers.neq, helpers.eq, helpers.command local clear, curbufmeths = helpers.clear, helpers.curbufmeths local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval @@ -118,7 +118,7 @@ describe('eval-API', function() end) it('are highlighted by vim.vim syntax file', function() - if lfs.attributes("build/runtime/syntax/vim/generated.vim",'uid') == nil then + if luv.fs_stat("build/runtime/syntax/vim/generated.vim").uid == nil then pending("runtime was not built, skipping test") return end diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index b521620320..7a54f479e0 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') local eq = helpers.eq local clear = helpers.clear @@ -16,6 +16,7 @@ local curtabmeths = helpers.curtabmeths local get_pathsep = helpers.get_pathsep local rmdir = helpers.rmdir local pcall_err = helpers.pcall_err +local mkdir = helpers.mkdir local fname = 'Xtest-functional-eval-buf_functions' local fname2 = fname .. '.2' @@ -62,7 +63,7 @@ describe('bufname() function', function() eq('', funcs.bufname('X')) end) before_each(function() - lfs.mkdir(dirname) + mkdir(dirname) end) after_each(function() rmdir(dirname) @@ -70,7 +71,7 @@ describe('bufname() function', function() it('returns expected buffer name', function() eq('', funcs.bufname('%')) -- Buffer has no name yet command('file ' .. fname) - local wd = lfs.currentdir() + local wd = luv.cwd() local sep = get_pathsep() local curdirname = funcs.fnamemodify(wd, ':t') for _, arg in ipairs({'%', 1, 'X', wd}) do @@ -103,7 +104,7 @@ describe('bufnr() function', function() it('returns expected buffer number', function() eq(1, funcs.bufnr('%')) command('file ' .. fname) - local wd = lfs.currentdir() + local wd = luv.cwd() local curdirname = funcs.fnamemodify(wd, ':t') eq(1, funcs.bufnr(fname)) eq(1, funcs.bufnr(wd)) @@ -144,7 +145,7 @@ describe('bufwinnr() function', function() eq(-1, funcs.bufwinnr('X')) end) before_each(function() - lfs.mkdir(dirname) + mkdir(dirname) end) after_each(function() rmdir(dirname) diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index a8a901042b..b995aaa5a6 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -12,7 +12,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local lfs = require('lfs') +local mkdir = helpers.mkdir local clear = helpers.clear local eq = helpers.eq local exc_exec = helpers.exc_exec @@ -56,11 +56,11 @@ end) describe("backtick expansion", function() setup(function() clear() - lfs.mkdir("test-backticks") + mkdir("test-backticks") write_file("test-backticks/file1", "test file 1") write_file("test-backticks/file2", "test file 2") write_file("test-backticks/file3", "test file 3") - lfs.mkdir("test-backticks/subdir") + mkdir("test-backticks/subdir") write_file("test-backticks/subdir/file4", "test file 4") -- Long path might cause "Press ENTER" prompt; use :silent to avoid it. command('silent cd test-backticks') diff --git a/test/functional/vimscript/glob_spec.lua b/test/functional/vimscript/glob_spec.lua index b8807ecfcc..948a63f050 100644 --- a/test/functional/vimscript/glob_spec.lua +++ b/test/functional/vimscript/glob_spec.lua @@ -1,17 +1,18 @@ -local lfs = require('lfs') +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 before_each(function() clear() - lfs.mkdir('test-glob') + mkdir('test-glob') -- Long path might cause "Press ENTER" prompt; use :silent to avoid it. command('silent cd test-glob') end) after_each(function() - lfs.rmdir('test-glob') + luv.fs_rmdir('test-glob') end) describe('glob()', function() diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua index 8c8da9dc88..c816efd37b 100644 --- a/test/functional/vimscript/writefile_spec.lua +++ b/test/functional/vimscript/writefile_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') +local mkdir = helpers.mkdir local clear = helpers.clear local eq = helpers.eq local funcs = helpers.funcs @@ -19,16 +20,16 @@ local ddname_tail = '2' local ddname = dname .. '/' .. ddname_tail before_each(function() - lfs.mkdir(dname) - lfs.mkdir(ddname) + mkdir(dname) + mkdir(ddname) clear() end) after_each(function() os.remove(fname) os.remove(dfname) - lfs.rmdir(ddname) - lfs.rmdir(dname) + luv.fs_rmdir(ddname) + luv.fs_rmdir(dname) end) describe('writefile()', function() |