mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: remove helpers.sleep()
This commit is contained in:
parent
d33e1da9b7
commit
7a259d01ae
@ -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 = {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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 |
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 = {}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -30,7 +30,7 @@ describe('vim.loader', function()
|
||||
)
|
||||
|
||||
-- fs latency
|
||||
helpers.sleep(10)
|
||||
vim.uv.sleep(10)
|
||||
|
||||
eq(
|
||||
2,
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -1706,7 +1706,7 @@ describe('extmark decorations', function()
|
||||
]]
|
||||
|
||||
for _ = 1, 3 do
|
||||
helpers.sleep(10)
|
||||
vim.uv.sleep(10)
|
||||
feed 'j'
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 = [[
|
||||
|
@ -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' }
|
||||
|
||||
|
@ -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
|
||||
|
@ -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'))
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user