tests: detect invalid helpers.sleep

This commit is contained in:
Björn Linse 2017-04-21 10:59:06 +02:00
parent 9cc9789681
commit 48f0542ad6
3 changed files with 12 additions and 3 deletions

View File

@ -41,7 +41,7 @@ describe("CTRL-C (mapped)", function()
local function test_ctrl_c(ms) local function test_ctrl_c(ms)
feed(":global/^/p<CR>") feed(":global/^/p<CR>")
helpers.sleep(ms) screen:sleep(ms)
feed("<C-C>") feed("<C-C>")
screen:expect([[Interrupt]], nil, nil, nil, true) screen:expect([[Interrupt]], nil, nil, nil, true)
end end

View File

@ -392,7 +392,16 @@ end
-- sleeps the test runner (_not_ the nvim instance) -- sleeps the test runner (_not_ the nvim instance)
local function sleep(ms) local function sleep(ms)
run(nil, nil, nil, ms) local function notification_cb(method, args)
local _ = args
if method == "redraw" then
error("helpers.sleep() called while screen is attached. "..
"Use screen:sleep(...) instead")
end
return true
end
run(nil, notification_cb, nil, ms)
end end
local function curbuf_contents() local function curbuf_contents()

View File

@ -26,7 +26,7 @@ describe(':terminal', function()
feed_command([[terminal while true; do echo X; done]]) feed_command([[terminal while true; do echo X; done]])
helpers.feed([[<C-\><C-N>]]) helpers.feed([[<C-\><C-N>]])
wait() wait()
screen.sleep(10) -- Let some terminal activity happen. screen:sleep(10) -- Let some terminal activity happen.
feed_command("messages") feed_command("messages")
screen:expect([[ screen:expect([[
msg1 | msg1 |