diff options
author | Daniel Hahler <git@thequod.de> | 2019-09-24 08:55:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-24 08:55:27 +0200 |
commit | 0ab7da8561bfcc4c644afb9cf48083a5696c1792 (patch) | |
tree | ed81acbdacb3f5d23163dfa2fc9bc249b907ec39 /test/functional/eval/timer_spec.lua | |
parent | 2476a97ced2a868b0dd2146618c9c5d77c1c84b1 (diff) | |
download | rneovim-0ab7da8561bfcc4c644afb9cf48083a5696c1792.tar.gz rneovim-0ab7da8561bfcc4c644afb9cf48083a5696c1792.tar.bz2 rneovim-0ab7da8561bfcc4c644afb9cf48083a5696c1792.zip |
timer_spec: fix/harden flaky tests (#11080)
Those are flaky when using luacov (which causes reproducible slowness).
E.g.:
[ ERROR ] test/functional\eval\timer_spec.lua @ 105: timers can invoke redraw in blocking getchar() call
test\functional\ui\screen.lua:587: Row 3 did not match.
Expected:
|ITEM 1 |
|ITEM 2 |
|*{1:~ }|
|{1:~ }|
|{1:~ }|
|^ |
Actual:
|ITEM 1 |
|ITEM 2 |
|*ITEM 3 |
|{1:~ }|
|{1:~ }|
|^ |
Diffstat (limited to 'test/functional/eval/timer_spec.lua')
-rw-r--r-- | test/functional/eval/timer_spec.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index 2ccb9cfbac..ef7df69fdb 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -111,7 +111,13 @@ describe('timers', function() curbufmeths.set_lines(0, -1, true, {"ITEM 1", "ITEM 2"}) source([[ + let g:cont = 0 func! AddItem(timer) + if !g:cont + return + endif + call timer_stop(a:timer) + call nvim_buf_set_lines(0, 2, 2, v:true, ['ITEM 3']) " Meant to test for what Vim tests in Test_peek_and_get_char. @@ -121,7 +127,7 @@ describe('timers', function() endfunc ]]) nvim_async("command", "let g:c2 = getchar()") - nvim_async("command", "call timer_start("..load_adjust(100)..", 'AddItem')") + nvim_async("command", "call timer_start("..load_adjust(100)..", 'AddItem', {'repeat': -1})") screen:expect([[ ITEM 1 | @@ -131,6 +137,7 @@ describe('timers', function() {1:~ }| ^ | ]]) + nvim_async("command", "let g:cont = 1") screen:expect([[ ITEM 1 | @@ -222,12 +229,17 @@ describe('timers', function() source([[ let g:val = 0 func! MyHandler(timer) + while !g:val + return + endwhile + call timer_stop(a:timer) + echo "evil" redraw - let g:val = 1 + let g:val = 2 endfunc ]]) - command("call timer_start(100, 'MyHandler', {'repeat': 1})") + command("call timer_start(100, 'MyHandler', {'repeat': -1})") feed(":good") screen:expect([[ | @@ -237,6 +249,7 @@ describe('timers', function() {0:~ }| :good^ | ]]) + command('let g:val = 1') screen:expect{grid=[[ | @@ -247,6 +260,6 @@ describe('timers', function() :good^ | ]], intermediate=true, timeout=load_adjust(200)} - eq(1, eval('g:val')) + eq(2, eval('g:val')) end) end) |