mirror of
https://github.com/neovim/neovim.git
synced 2025-11-06 02:34:28 +00:00
test: Add synchronization helper for functional tests
The `wait` function will only return after all input has been processed by nvim. It is useful to time assertions correctly.
This commit is contained in:
@@ -229,11 +229,15 @@ local function curbuf(method, ...)
|
|||||||
return buffer(method, buf, ...)
|
return buffer(method, buf, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function wait()
|
||||||
|
session:request('vim_eval', '1')
|
||||||
|
end
|
||||||
|
|
||||||
local function curbuf_contents()
|
local function curbuf_contents()
|
||||||
-- Before inspecting the buffer, execute 'vim_eval' to wait until all
|
-- Before inspecting the buffer, execute 'vim_eval' to wait until all
|
||||||
-- previously sent keys are processed(vim_eval is a deferred function, and
|
-- previously sent keys are processed(vim_eval is a deferred function, and
|
||||||
-- only processed after all input)
|
-- only processed after all input)
|
||||||
session:request('vim_eval', '1')
|
wait()
|
||||||
return table.concat(curbuf('get_line_slice', 0, -1, true, true), '\n')
|
return table.concat(curbuf('get_line_slice', 0, -1, true, true), '\n')
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -284,5 +288,6 @@ return {
|
|||||||
curbuf = curbuf,
|
curbuf = curbuf,
|
||||||
curwin = curwin,
|
curwin = curwin,
|
||||||
curtab = curtab,
|
curtab = curtab,
|
||||||
curbuf_contents = curbuf_contents
|
curbuf_contents = curbuf_contents,
|
||||||
|
wait = wait
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user