aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2015-03-22 15:23:53 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2015-04-03 09:05:04 -0300
commit1e7624d2a0a4be9a7e898994728064eb88a91576 (patch)
treed578408b08790528909ea8856e09e9b9031e2d9c
parente5c4c4bca20678e6c621847f370701945ce625db (diff)
downloadrneovim-1e7624d2a0a4be9a7e898994728064eb88a91576.tar.gz
rneovim-1e7624d2a0a4be9a7e898994728064eb88a91576.tar.bz2
rneovim-1e7624d2a0a4be9a7e898994728064eb88a91576.zip
tests/ui: warn when the correct state was seen temporarily.
Helped-by: Thiago de Arruda <tpadilha84@gmail.com>
-rw-r--r--test/functional/ui/screen.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 6c23611c07..ca6cac1ba3 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -230,20 +230,41 @@ end
function Screen:wait(check, timeout)
local err, checked = false
+ local success_seen = false
+ local failure_after_success = false
local function notification_cb(method, args)
assert(method == 'redraw')
self:_redraw(args)
err = check()
checked = true
if not err then
+ success_seen = true
stop()
+ elseif success_seen and #args > 0 then
+ failure_after_success = true
+ --print(require('inspect')(args))
end
+
return true
end
run(nil, notification_cb, nil, timeout or default_screen_timeout)
if not checked then
err = check()
end
+
+ if failure_after_success then
+ print([[
+Warning: Screen changes have been received after the expected state was seen.
+This is probably due to an indeterminism in the test. Try adding
+`wait()` (or even a separate `screen:expect(...)`) at a point of possible
+indeterminism, typically in between a `feed()` or `execute()` which is non-
+synchronous, and a synchronous api call.
+ ]])
+ local tb = debug.traceback()
+ local index = string.find(tb, '\n%s*%[C]')
+ print(string.sub(tb,1,index))
+ end
+
if err then
assert(false, err)
end