aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-10-08 08:56:13 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-10-13 23:34:49 +0200
commite39dade80b023bc6ac1b5592d1e1637d0c1a2502 (patch)
tree3331d6e2ba372d40bf3485e46836c423a2d4c8fc
parent0995f460fbebdfd7d76b8932f73ea958033c92b1 (diff)
downloadrneovim-e39dade80b023bc6ac1b5592d1e1637d0c1a2502.tar.gz
rneovim-e39dade80b023bc6ac1b5592d1e1637d0c1a2502.tar.bz2
rneovim-e39dade80b023bc6ac1b5592d1e1637d0c1a2502.zip
test: adjust timer tests
Timer tests are less reliable on Travis CI macOS 10.12 (most egregious). Also somewhat on 10.13.
-rw-r--r--src/nvim/testdir/test_timers.vim7
-rw-r--r--test/functional/eval/timer_spec.lua10
2 files changed, 11 insertions, 6 deletions
diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim
index 6450bf02e8..82afeb76c8 100644
--- a/src/nvim/testdir/test_timers.vim
+++ b/src/nvim/testdir/test_timers.vim
@@ -20,9 +20,9 @@ func Test_oneshot()
let slept = WaitFor('g:val == 1')
call assert_equal(1, g:val)
if has('reltime')
- call assert_inrange(40, 100, slept)
+ call assert_inrange(40, 120, slept)
else
- call assert_inrange(20, 100, slept)
+ call assert_inrange(20, 120, slept)
endif
endfunc
@@ -39,6 +39,7 @@ func Test_repeat_three()
endfunc
func Test_repeat_many()
+ call timer_stopall()
let g:val = 0
let timer = timer_start(50, 'MyHandler', {'repeat': -1})
sleep 200m
@@ -89,6 +90,7 @@ func Test_info()
endfunc
func Test_stopall()
+ call timer_stopall()
let id1 = timer_start(1000, 'MyHandler')
let id2 = timer_start(2000, 'MyHandler')
let info = timer_info()
@@ -161,6 +163,7 @@ func StopTimerAll(timer)
endfunc
func Test_stop_all_in_callback()
+ call timer_stopall()
let g:timer1 = timer_start(10, 'StopTimerAll')
let info = timer_info()
call assert_equal(1, len(info))
diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua
index 8afc3592cc..040ab30522 100644
--- a/test/functional/eval/timer_spec.lua
+++ b/test/functional/eval/timer_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local ok, feed, eq, eval = helpers.ok, helpers.feed, helpers.eq, helpers.eval
+local feed, eq, eval = helpers.feed, helpers.eq, helpers.eval
local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run
local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs
local curbufmeths = helpers.curbufmeths
@@ -72,7 +72,8 @@ describe('timers', function()
run(nil, nil, nil, 300)
feed("<cr>")
local diff = eval("g:val") - count
- ok(0 <= diff and diff <= 4)
+ assert(0 <= diff and diff <= 4,
+ 'expected (0 <= diff <= 4), got: '..tostring(diff))
end)
it('are triggered in blocking getchar() call', function()
@@ -81,7 +82,7 @@ describe('timers', function()
run(nil, nil, nil, 300)
feed("c")
local count = eval("g:val")
- ok(count >= 4)
+ assert(count >= 4, 'expected count >= 4, got: '..tostring(count))
eq(99, eval("g:c"))
end)
@@ -142,9 +143,10 @@ describe('timers', function()
local count = eval("g:val")
run(nil, nil, nil, 300)
local count2 = eval("g:val")
- ok(4 <= count and count <= 7)
-- when count is eval:ed after timer_stop this should be non-racy
eq(count, count2)
+ assert(4 <= count and count <= 7,
+ 'expected (4 <= count <= 7), got: '..tostring(count))
end)
it('can be stopped from the handler', function()