mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: helpers.retry()
This commit is contained in:
parent
8da23cb919
commit
1a4f13ba8f
@ -243,6 +243,19 @@ local function connect(file_or_address)
|
|||||||
return Session.new(stream)
|
return Session.new(stream)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Calls fn() until it returns without error, up to `max` times.
|
||||||
|
local function retry(fn, max)
|
||||||
|
local retries = max and (max - 1) or 2
|
||||||
|
for _ = 1, retries do
|
||||||
|
local success = pcall(fn)
|
||||||
|
if success then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- pcall() is not used for the final attempt so failure can bubble up.
|
||||||
|
fn()
|
||||||
|
end
|
||||||
|
|
||||||
local function clear(...)
|
local function clear(...)
|
||||||
local args = {unpack(nvim_argv)}
|
local args = {unpack(nvim_argv)}
|
||||||
local new_args
|
local new_args
|
||||||
@ -530,6 +543,7 @@ return function(after_each)
|
|||||||
prepend_argv = prepend_argv,
|
prepend_argv = prepend_argv,
|
||||||
clear = clear,
|
clear = clear,
|
||||||
connect = connect,
|
connect = connect,
|
||||||
|
retry = retry,
|
||||||
spawn = spawn,
|
spawn = spawn,
|
||||||
dedent = dedent,
|
dedent = dedent,
|
||||||
source = source,
|
source = source,
|
||||||
|
@ -98,15 +98,7 @@ describe('undo tree:', function()
|
|||||||
expect_line('123456abc')
|
expect_line('123456abc')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Retry up to 3 times. pcall() is _not_ used for the final attempt, so
|
helpers.retry(test_earlier_later)
|
||||||
-- that failure messages can bubble up.
|
|
||||||
for _ = 1, 2 do
|
|
||||||
local success = pcall(test_earlier_later)
|
|
||||||
if success then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
test_earlier_later()
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('file-write specifications', function()
|
it('file-write specifications', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user