aboutsummaryrefslogtreecommitdiff
path: root/test/functional/helpers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/helpers.lua')
-rw-r--r--test/functional/helpers.lua35
1 files changed, 8 insertions, 27 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index a14bedbbbd..6400db9f87 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -1,5 +1,4 @@
require('coxpcall')
-local busted = require('busted')
local luv = require('luv')
local lfs = require('lfs')
local mpack = require('mpack')
@@ -397,9 +396,12 @@ local function remove_args(args, args_rm)
return new_args
end
-function module.check_close(old_session)
+function module.check_close()
+ if not session then
+ return
+ end
local start_time = luv.now()
- old_session:close()
+ session:close()
luv.update_time() -- Update cached value of luv.now() (libuv: uv_now()).
local end_time = luv.now()
local delta = end_time - start_time
@@ -408,12 +410,13 @@ function module.check_close(old_session)
"This indicates a likely problem with the test even if it passed!\n")
io.stdout:flush()
end
+ session = nil
end
--- @param io_extra used for stdin_fd, see :help ui-option
function module.spawn(argv, merge, env, keep, io_extra)
- if session and not keep then
- module.check_close(session)
+ if not keep then
+ module.check_close()
end
local child_stream = ChildProcessStream.spawn(
@@ -430,28 +433,6 @@ function module.connect(file_or_address)
return Session.new(stream)
end
--- Calls fn() until it succeeds, up to `max` times or until `max_ms`
--- milliseconds have passed.
-function module.retry(max, max_ms, fn)
- assert(max == nil or max > 0)
- assert(max_ms == nil or max_ms > 0)
- local tries = 1
- local timeout = (max_ms and max_ms or 10000)
- local start_time = luv.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
- busted.fail(string.format("retry() attempts: %d\n%s", tries, tostring(result)), 2)
- end
- tries = tries + 1
- luv.sleep(20) -- Avoid hot loop...
- end
-end
-
-- Starts a new global Nvim session.
--
-- Parameters are interpreted as startup args, OR a map with these keys: