test/functional: sleep()

This commit is contained in:
Justin M. Keyes
2016-06-22 02:18:21 -04:00
parent c402f6e7a9
commit 086aa99292

View File

@@ -300,14 +300,18 @@ local function curbuf(method, ...)
end end
local function wait() local function wait()
-- Execute 'vim_eval' (a deferred function) to block
-- until all pending input is processed.
session:request('vim_eval', '1') session:request('vim_eval', '1')
end end
-- sleeps the test runner (_not_ the nvim instance)
local function sleep(timeout)
run(nil, nil, nil, timeout)
end
local function curbuf_contents() local function curbuf_contents()
-- Before inspecting the buffer, execute 'vim_eval' to wait until all wait() -- Before inspecting the buffer, process all input.
-- previously sent keys are processed(vim_eval is a deferred function, and
-- only processed after all input)
wait()
return table.concat(curbuf('get_lines', 0, -1, true), '\n') return table.concat(curbuf('get_lines', 0, -1, true), '\n')
end end
@@ -441,6 +445,7 @@ return function(after_each)
curtab = curtab, curtab = curtab,
curbuf_contents = curbuf_contents, curbuf_contents = curbuf_contents,
wait = wait, wait = wait,
sleep = sleep,
set_session = set_session, set_session = set_session,
write_file = write_file, write_file = write_file,
os_name = os_name, os_name = os_name,