diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 11:41:09 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2024-01-12 12:04:19 +0000 |
commit | 7a259d01aed52134a1675e47d9054ccad7ef7cbb (patch) | |
tree | ae3741677b97f408e589d55a3f7e5b863d1e1b58 | |
parent | d33e1da9b7f7e886219cfdd20b9bbfaccdc43be9 (diff) | |
download | rneovim-7a259d01aed52134a1675e47d9054ccad7ef7cbb.tar.gz rneovim-7a259d01aed52134a1675e47d9054ccad7ef7cbb.tar.bz2 rneovim-7a259d01aed52134a1675e47d9054ccad7ef7cbb.zip |
test: remove helpers.sleep()
28 files changed, 58 insertions, 60 deletions
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index b0efcf0dab..af6404fe7f 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -6,7 +6,7 @@ local buffer, command, eval, nvim, next_msg = helpers.buffer, helpers.command, helpers.eval, helpers.nvim, helpers.next_msg local nvim_prog = helpers.nvim_prog local pcall_err = helpers.pcall_err -local sleep = helpers.sleep +local sleep = vim.uv.sleep local write_file = helpers.write_file local origlines = { diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 50c353d764..789ad28544 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -14,7 +14,7 @@ local source = helpers.source local pcall_err = helpers.pcall_err local shallowcopy = helpers.shallowcopy -local sleep = helpers.sleep +local sleep = vim.uv.sleep local sid_api_client = -9 local sid_lua = -8 diff --git a/test/functional/autocmd/cursorhold_spec.lua b/test/functional/autocmd/cursorhold_spec.lua index 535881b6cc..67ccf86ea4 100644 --- a/test/functional/autocmd/cursorhold_spec.lua +++ b/test/functional/autocmd/cursorhold_spec.lua @@ -5,7 +5,7 @@ local eq = helpers.eq local feed = helpers.feed local retry = helpers.retry local exec = helpers.source -local sleep = helpers.sleep +local sleep = vim.uv.sleep local meths = helpers.meths before_each(clear) diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index 0b58e8bc54..570dda0730 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eq, eval, next_msg, ok, source = helpers.clear, helpers.eq, helpers.eval, helpers.next_msg, helpers.ok, helpers.source local command, funcs, meths = helpers.command, helpers.funcs, helpers.meths -local sleep = helpers.sleep +local sleep = vim.uv.sleep local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv local set_session = helpers.set_session local nvim_prog = helpers.nvim_prog diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index 3aaa4383b4..6b821869ee 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -17,7 +17,7 @@ local rmdir = helpers.rmdir local matches = helpers.matches local meths = helpers.meths local mkdir = helpers.mkdir -local sleep = helpers.sleep +local sleep = vim.uv.sleep local read_file = helpers.read_file local trim = vim.trim local currentdir = helpers.funcs.getcwd @@ -295,7 +295,6 @@ describe('fileio', function() local future_time = cur_unix_time + 999999 -- Set the file's access/update time to be -- greater than the time at which it was created. - local uv = require('luv') uv.fs_utime('Xtest-overwrite-forced', future_time, future_time) -- use async feed_command because nvim basically hangs on the prompt feed_command('w') diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 210007f027..e1baa6f48f 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -1177,7 +1177,7 @@ describe('jobs', function() -- Have to wait so that the SIGHUP can be processed by tty-test on time. -- Can't wait for the next message in case this test fails, if it fails -- there won't be any more messages, and the test would hang. - helpers.sleep(100) + vim.uv.sleep(100) local err = exc_exec('call jobpid(j)') eq('Vim(call):E900: Invalid channel id', err) diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 7953a101e1..5d2da8f5e0 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -22,7 +22,7 @@ local nvim_set = helpers.nvim_set local read_file = helpers.read_file local retry = helpers.retry local rmdir = helpers.rmdir -local sleep = helpers.sleep +local sleep = vim.uv.sleep local startswith = vim.startswith local write_file = helpers.write_file local meths = helpers.meths diff --git a/test/functional/editor/K_spec.lua b/test/functional/editor/K_spec.lua index 92a00b28b6..1107de7984 100644 --- a/test/functional/editor/K_spec.lua +++ b/test/functional/editor/K_spec.lua @@ -36,7 +36,7 @@ describe('K', function() end) eq({ 'fnord' }, eval("readfile('" .. test_file .. "')")) -- Confirm that Neovim is still in terminal mode after K is pressed (#16692). - helpers.sleep(500) + vim.uv.sleep(500) eq('t', eval('mode()')) feed('<space>') -- Any key, not just <space>, can be used here to escape. eq('n', eval('mode()')) @@ -50,7 +50,7 @@ describe('K', function() -- Confirm that an arbitrary keypress doesn't escape (i.e., the process is -- still running). If the process were no longer running, an arbitrary -- keypress would escape. - helpers.sleep(500) + vim.uv.sleep(500) feed('<space>') eq('t', eval('mode()')) -- Confirm that <esc> kills the buffer for the running command. diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index fbb63fdba6..c13222bd7a 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -691,7 +691,7 @@ describe('completion', function() ]]) -- Works for unindenting too. feed('ounin<C-X><C-N>') - helpers.poke_eventloop() + poke_eventloop() feed('<BS>d') screen:expect([[ inc uninc indent unindent | @@ -1067,7 +1067,7 @@ describe('completion', function() {3:-- }{4:match 1 of 3} | ]]) command([[call timer_start(100, { -> execute('stopinsert') })]]) - helpers.sleep(200) + vim.uv.sleep(200) feed('k') -- cursor should move up in Normal mode screen:expect([[ hello | diff --git a/test/functional/editor/ctrl_c_spec.lua b/test/functional/editor/ctrl_c_spec.lua index 0321a21b35..e6a6ea808a 100644 --- a/test/functional/editor/ctrl_c_spec.lua +++ b/test/functional/editor/ctrl_c_spec.lua @@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear, feed, source = helpers.clear, helpers.feed, helpers.source local command = helpers.command local poke_eventloop = helpers.poke_eventloop -local sleep = helpers.sleep +local sleep = vim.uv.sleep describe('CTRL-C (mapped)', function() local screen diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index 1885963bbc..cc3a81f7dd 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -10,7 +10,7 @@ local funcs = helpers.funcs local matches = helpers.matches local pesc = vim.pesc local rmdir = helpers.rmdir -local sleep = helpers.sleep +local sleep = vim.uv.sleep local meths = helpers.meths local skip = helpers.skip local is_os = helpers.is_os diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index e4342d1dc0..763b3c8663 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -12,7 +12,7 @@ local dedent = global_helpers.dedent local eq = global_helpers.eq local is_os = global_helpers.is_os local ok = global_helpers.ok -local sleep = global_helpers.sleep +local sleep = uv.sleep local fail = global_helpers.fail local module = {} diff --git a/test/functional/legacy/edit_spec.lua b/test/functional/legacy/edit_spec.lua index 59e9805a91..0762e5e671 100644 --- a/test/functional/legacy/edit_spec.lua +++ b/test/functional/legacy/edit_spec.lua @@ -4,7 +4,7 @@ local clear = helpers.clear local command = helpers.command local expect = helpers.expect local feed = helpers.feed -local sleep = helpers.sleep +local sleep = vim.uv.sleep before_each(clear) diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 28efb912f8..46c9a869ac 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -4,7 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local expect, poke_eventloop = helpers.expect, helpers.poke_eventloop local command, eq, eval, meths = helpers.command, helpers.eq, helpers.eval, helpers.meths -local sleep = helpers.sleep +local sleep = vim.uv.sleep describe('mapping', function() before_each(clear) diff --git a/test/functional/lua/highlight_spec.lua b/test/functional/lua/highlight_spec.lua index 8e499f1e79..f304bec411 100644 --- a/test/functional/lua/highlight_spec.lua +++ b/test/functional/lua/highlight_spec.lua @@ -16,7 +16,7 @@ describe('vim.highlight.on_yank', function() vim.highlight.on_yank({timeout = 10, on_macro = true, event = {operator = "y", regtype = "v"}}) vim.cmd('bwipeout!') ]]) - helpers.sleep(10) + vim.uv.sleep(10) helpers.feed('<cr>') -- avoid hang if error message exists eq('', eval('v:errmsg')) end) diff --git a/test/functional/lua/loader_spec.lua b/test/functional/lua/loader_spec.lua index 92dd2296cb..cdb561330a 100644 --- a/test/functional/lua/loader_spec.lua +++ b/test/functional/lua/loader_spec.lua @@ -30,7 +30,7 @@ describe('vim.loader', function() ) -- fs latency - helpers.sleep(10) + vim.uv.sleep(10) eq( 2, diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua index e46dbe7455..38d6f1c24f 100644 --- a/test/functional/lua/loop_spec.lua +++ b/test/functional/lua/loop_spec.lua @@ -4,7 +4,7 @@ local Screen = require('test.functional.ui.screen') local funcs = helpers.funcs local meths = helpers.meths local clear = helpers.clear -local sleep = helpers.sleep +local sleep = vim.uv.sleep local feed = helpers.feed local eq = helpers.eq local eval = helpers.eval diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua index defd13429e..bf73e6c6fd 100644 --- a/test/functional/lua/snippet_spec.lua +++ b/test/functional/lua/snippet_spec.lua @@ -7,7 +7,7 @@ local exec_lua = helpers.exec_lua local feed = helpers.feed local matches = helpers.matches local pcall_err = helpers.pcall_err -local sleep = helpers.sleep +local sleep = vim.uv.sleep describe('vim.snippet', function() before_each(function() diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 497d7668e8..48a38864d6 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -15,7 +15,7 @@ local command = helpers.command local exc_exec = helpers.exc_exec local matches = helpers.matches local exec_lua = helpers.exec_lua -local sleep = helpers.sleep +local sleep = vim.uv.sleep local funcs = helpers.funcs local is_os = helpers.is_os local skip = helpers.skip diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index 1fb759b571..846188685b 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -8,7 +8,7 @@ local command = helpers.command local eq = helpers.eq local eval = helpers.eval local meths = helpers.meths -local sleep = helpers.sleep +local sleep = vim.uv.sleep local retry = helpers.retry local is_os = helpers.is_os diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index d6a0205b7e..6ff2a12ded 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1706,7 +1706,7 @@ describe('extmark decorations', function() ]] for _ = 1, 3 do - helpers.sleep(10) + vim.uv.sleep(10) feed 'j' end diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 6b64928622..60bdf97b79 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -15,7 +15,7 @@ local retry = helpers.retry local source = helpers.source local poke_eventloop = helpers.poke_eventloop local nvim = helpers.nvim -local sleep = helpers.sleep +local sleep = vim.uv.sleep local testprg = helpers.testprg local assert_alive = helpers.assert_alive diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 92bc6a7f76..7cb8d4622d 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -154,7 +154,7 @@ describe('input split utf sequences', function() it('ok', function() local str = '►' feed('i' .. str:sub(1, 1)) - helpers.sleep(10) + vim.uv.sleep(10) feed(str:sub(2, 3)) expect('►') end) @@ -163,7 +163,7 @@ describe('input split utf sequences', function() command('inoremap ► E296BA') local str = '►' feed('i' .. str:sub(1, 1)) - helpers.sleep(10) + vim.uv.sleep(10) feed(str:sub(2, 3)) expect('E296BA') end) diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index da0a68edcb..94b4ead434 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1650,7 +1650,7 @@ describe('builtin popupmenu', function() -- test nvim_complete_set_info feed('<C-N><C-N>') - helpers.sleep(10) + vim.uv.sleep(10) if multigrid then screen:expect { grid = [[ diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 873f529097..7e6d336ff9 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -10,7 +10,7 @@ local meths = helpers.meths local exec = helpers.exec local exec_lua = helpers.exec_lua local eval = helpers.eval -local sleep = helpers.sleep +local sleep = vim.uv.sleep local mousemodels = { 'extend', 'popup', 'popup_setpos' } diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua index a562f6f888..da8be7e90c 100644 --- a/test/functional/vimscript/eval_spec.lua +++ b/test/functional/vimscript/eval_spec.lua @@ -23,7 +23,7 @@ local eval = helpers.eval local command = helpers.command local write_file = helpers.write_file local meths = helpers.meths -local sleep = helpers.sleep +local sleep = vim.uv.sleep local matches = helpers.matches local pcall_err = helpers.pcall_err local assert_alive = helpers.assert_alive diff --git a/test/helpers.lua b/test/helpers.lua index 0f854e5695..83d7a0ece6 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -1,17 +1,19 @@ local luaassert = require('luassert') local busted = require('busted') -local luv = require('luv') +local uv = vim.uv local Paths = require('test.cmakeconfig.paths') luaassert:set_parameter('TableFormatLevel', 100) local quote_me = '[^.%w%+%-%@%_%/]' -- complement (needn't quote) + +--- @param str string +--- @return string local function shell_quote(str) if string.find(str, quote_me) or str == '' then return '"' .. str:gsub('[$%%"\\]', '\\%0') .. '"' - else - return str end + return str end --- @class test.helpers @@ -23,7 +25,7 @@ local module = { --- @return string local function relpath(p) p = vim.fs.normalize(p) - local cwd = luv.cwd() + local cwd = uv.cwd() return p:gsub('^' .. cwd) end @@ -33,7 +35,7 @@ function module.isdir(path) if not path then return false end - local stat = luv.fs_stat(path) + local stat = uv.fs_stat(path) if not stat then return false end @@ -46,7 +48,7 @@ function module.isfile(path) if not path then return false end - local stat = luv.fs_stat(path) + local stat = uv.fs_stat(path) if not stat then return false end @@ -73,11 +75,6 @@ function module.popen_r(...) return io.popen(module.argss_to_cmd(...), 'r') end --- sleeps the test runner (_not_ the nvim instance) -function module.sleep(ms) - luv.sleep(ms) -end - -- Calls fn() until it succeeds, up to `max` times or until `max_ms` -- milliseconds have passed. function module.retry(max, max_ms, fn) @@ -85,18 +82,18 @@ function module.retry(max, max_ms, fn) luaassert(max_ms == nil or max_ms > 0) local tries = 1 local timeout = (max_ms and max_ms or 10000) - local start_time = luv.now() + local start_time = uv.now() while true do local status, result = pcall(fn) if status then return result end - luv.update_time() -- Update cached value of luv.now() (libuv: uv_now()). - if (max and tries >= max) or (luv.now() - start_time > timeout) then + uv.update_time() -- Update cached value of luv.now() (libuv: uv_now()). + if (max and tries >= max) or (uv.now() - start_time > timeout) then busted.fail(string.format('retry() attempts: %d\n%s', tries, tostring(result)), 2) end tries = tries + 1 - luv.sleep(20) -- Avoid hot loop... + uv.sleep(20) -- Avoid hot loop... end end @@ -289,7 +286,7 @@ function module.glob(initial_path, re, exc_re) local full_path = cur_path .. '/' .. e local checked_path = full_path:sub(#initial_path + 1) if (not is_excluded(checked_path)) and e:sub(1, 1) ~= '.' then - local stat = luv.fs_stat(full_path) + local stat = uv.fs_stat(full_path) if stat then local check_key = stat.dev .. ':' .. tostring(stat.ino) if not checked_files[check_key] then @@ -356,7 +353,7 @@ function module.check_logs() end function module.sysname() - local platform = luv.os_uname() + local platform = uv.os_uname() if platform and platform.sysname then return platform.sysname:lower() end @@ -376,7 +373,7 @@ function module.is_os(s) end function module.is_arch(s) - local machine = luv.os_uname().machine + local machine = uv.os_uname().machine if s == 'arm64' or s == 'aarch64' then return machine == 'arm64' or machine == 'aarch64' end @@ -948,9 +945,11 @@ function module.read_nvim_log(logfile, ci_rename) return log end +--- @param path string +--- @return string function module.mkdir(path) -- 493 is 0755 in decimal - return luv.fs_mkdir(path, 493) + return uv.fs_mkdir(path, 493) end module = vim.tbl_extend('error', module, Paths, require('test.deprecated')) diff --git a/test/unit/undo_spec.lua b/test/unit/undo_spec.lua index 220a4733df..0e2f38a8c8 100644 --- a/test/unit/undo_spec.lua +++ b/test/unit/undo_spec.lua @@ -1,8 +1,8 @@ local helpers = require('test.unit.helpers')(after_each) local itp = helpers.gen_itp(it) -local luv = require('luv') +local uv = vim.uv local child_call_once = helpers.child_call_once -local sleep = helpers.sleep +local sleep = uv.sleep local ffi = helpers.ffi local cimport = helpers.cimport @@ -42,13 +42,13 @@ end) describe('u_write_undo', function() setup(function() mkdir('unit-test-directory') - luv.chdir('unit-test-directory') - options.p_udir = to_cstr(luv.cwd()) -- set p_udir to be the test dir + uv.chdir('unit-test-directory') + options.p_udir = to_cstr(uv.cwd()) -- set p_udir to be the test dir end) teardown(function() - luv.chdir('..') - local success, err = luv.fs_rmdir('unit-test-directory') + uv.chdir('..') + local success, err = uv.fs_rmdir('unit-test-directory') if not success then print(err) -- inform tester if directory fails to delete end @@ -99,7 +99,7 @@ describe('u_write_undo', function() local test_permission_file = io.open(test_file_name, 'w') test_permission_file:write('testing permissions') test_permission_file:close() - local test_permissions = luv.fs_stat(test_file_name).mode + local test_permissions = uv.fs_stat(test_file_name).mode -- Create vim buffer local c_file = to_cstr(test_file_name) @@ -112,7 +112,7 @@ describe('u_write_undo', function() local undo_file_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false)) -- Find out the permissions of the new file - local permissions = luv.fs_stat(undo_file_name).mode + local permissions = uv.fs_stat(undo_file_name).mode eq(test_permissions, permissions) -- delete the file now that we're done with it. @@ -137,7 +137,7 @@ describe('u_write_undo', function() u_write_undo(undo_file_name, false, file_buffer, buffer_hash) -- Find out the permissions of the new file - local permissions = luv.fs_stat(undo_file_name).mode + local permissions = uv.fs_stat(undo_file_name).mode eq(correct_permissions, permissions) -- delete the file now that we're done with it. @@ -169,13 +169,13 @@ describe('u_write_undo', function() u_write_undo(nil, false, file_buffer, buffer_hash) local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false)) - local file_last_modified = luv.fs_stat(correct_name).mtime.sec + local file_last_modified = uv.fs_stat(correct_name).mtime.sec sleep(1000) -- Ensure difference in timestamps. file_buffer.b_u_numhead = 1 -- Mark it as if there are changes u_write_undo(nil, false, file_buffer, buffer_hash) - local file_last_modified_2 = luv.fs_stat(correct_name).mtime.sec + local file_last_modified_2 = uv.fs_stat(correct_name).mtime.sec -- print(file_last_modified, file_last_modified_2) neq(file_last_modified, file_last_modified_2) |