From e6208df73e39e281331141373c22a83bca6beccd Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 12 Feb 2015 13:29:48 -0300 Subject: 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. --- test/functional/helpers.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index ea98ff4ce3..fc6bf80d7e 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -229,11 +229,15 @@ local function curbuf(method, ...) return buffer(method, buf, ...) end +local function wait() + session:request('vim_eval', '1') +end + local function curbuf_contents() -- Before inspecting the buffer, execute 'vim_eval' to wait until all -- previously sent keys are processed(vim_eval is a deferred function, and -- only processed after all input) - session:request('vim_eval', '1') + wait() return table.concat(curbuf('get_line_slice', 0, -1, true, true), '\n') end @@ -284,5 +288,6 @@ return { curbuf = curbuf, curwin = curwin, curtab = curtab, - curbuf_contents = curbuf_contents + curbuf_contents = curbuf_contents, + wait = wait } -- cgit