aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-19 20:27:25 +0800
committerGitHub <noreply@github.com>2022-07-19 20:27:25 +0800
commit078e4461812ce2a35919b08cf1cd658aa1889dc8 (patch)
tree73e80635ccc97ffcf41c711fae4a7a8db68c1a1e /test/functional/helpers.lua
parent101fd04ee2036b125a93f3e71dbaa4ae6917ce8b (diff)
parent72dfd57e5f45357db36155b79d7873cd0fc3dfaf (diff)
downloadrneovim-078e4461812ce2a35919b08cf1cd658aa1889dc8.tar.gz
rneovim-078e4461812ce2a35919b08cf1cd658aa1889dc8.tar.bz2
rneovim-078e4461812ce2a35919b08cf1cd658aa1889dc8.zip
Merge pull request #19429 from zeertzjq/fix-flaky-tests
fix flaky tests
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 0c616e73fb..8c5a60657a 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -271,10 +271,22 @@ function module.command(cmd)
end
--- use for commands which expect nvim to quit
-function module.expect_exit(...)
- eq("EOF was received from Nvim. Likely the Nvim process crashed.",
- module.pcall_err(...))
+-- Use for commands which expect nvim to quit.
+-- The first argument can also be a timeout.
+function module.expect_exit(fn_or_timeout, ...)
+ local eof_err_msg = 'EOF was received from Nvim. Likely the Nvim process crashed.'
+ if type(fn_or_timeout) == 'function' then
+ eq(eof_err_msg, module.pcall_err(fn_or_timeout, ...))
+ else
+ eq(eof_err_msg, module.pcall_err(function(timeout, fn, ...)
+ fn(...)
+ while session:next_message(timeout) do
+ end
+ if session.eof_err then
+ error(session.eof_err[2])
+ end
+ end, fn_or_timeout, ...))
+ end
end
-- Evaluates a VimL expression.