mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
test/functional: retry/Screen: failure instead of error #11173
- Running out of retries, or unexpected screen state should make the test FAIL, not ERROR. - Uses levels to report the location of the caller. - Improve message with retry-failure (formatting). Before: [ RUN ] test: 103.53 ms ERR test/functional/helpers.lua:388: retry() attempts: 1 test/functional/ui/screen.lua:587: Row 1 did not match. Expected: |*X^ | |{0:~ }| |{0:~ }| | | Actual: |*^ | |{0:~ }| |{0:~ }| | | To print the expect() call that would assert the current screen state, use screen:snapshot_util(). In case of non-deterministic failures, use screen:redraw_debug() to show all intermediate screen states. stack traceback: test/functional/helpers.lua:388: in function 'retry' test/functional/test_spec.lua:24: in function <test/functional/test_spec.lua:23> After: [ RUN ] test: 105.22 ms FAIL test/functional/test_spec.lua:24: stopping after 1 retry() attempts. test/functional/test_spec.lua:25: Row 1 did not match. Expected: |*X^ | |{0:~ }| |{0:~ }| | | Actual: |*^ | |{0:~ }| |{0:~ }| | | To print the expect() call that would assert the current screen state, use screen:snapshot_util(). In case of non-deterministic failures, use screen:redraw_debug() to show all intermediate screen states. stack traceback: test/functional/helpers.lua:389: in function 'retry' test/functional/test_spec.lua:24: in function <test/functional/test_spec.lua:23>
This commit is contained in:

committed by
Justin M. Keyes

parent
3de4dc539a
commit
d89ec55c45
@@ -1,4 +1,5 @@
|
||||
require('coxpcall')
|
||||
local busted = require('busted')
|
||||
local luv = require('luv')
|
||||
local lfs = require('lfs')
|
||||
local mpack = require('mpack')
|
||||
@@ -385,7 +386,7 @@ function module.retry(max, max_ms, fn)
|
||||
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
|
||||
error("\nretry() attempts: "..tostring(tries).."\n"..tostring(result))
|
||||
busted.fail(string.format("retry() attempts: %d\n%s", tries, tostring(result)), 2)
|
||||
end
|
||||
tries = tries + 1
|
||||
luv.sleep(20) -- Avoid hot loop...
|
||||
|
Reference in New Issue
Block a user