mirror of
https://github.com/neovim/neovim.git
synced 2025-10-22 17:11:49 +00:00
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:~ }|
|^ |
This commit is contained in:
@@ -111,7 +111,13 @@ describe('timers', function()
|
|||||||
|
|
||||||
curbufmeths.set_lines(0, -1, true, {"ITEM 1", "ITEM 2"})
|
curbufmeths.set_lines(0, -1, true, {"ITEM 1", "ITEM 2"})
|
||||||
source([[
|
source([[
|
||||||
|
let g:cont = 0
|
||||||
func! AddItem(timer)
|
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'])
|
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.
|
" Meant to test for what Vim tests in Test_peek_and_get_char.
|
||||||
@@ -121,7 +127,7 @@ describe('timers', function()
|
|||||||
endfunc
|
endfunc
|
||||||
]])
|
]])
|
||||||
nvim_async("command", "let g:c2 = getchar()")
|
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([[
|
screen:expect([[
|
||||||
ITEM 1 |
|
ITEM 1 |
|
||||||
@@ -131,6 +137,7 @@ describe('timers', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
^ |
|
^ |
|
||||||
]])
|
]])
|
||||||
|
nvim_async("command", "let g:cont = 1")
|
||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
ITEM 1 |
|
ITEM 1 |
|
||||||
@@ -222,12 +229,17 @@ describe('timers', function()
|
|||||||
source([[
|
source([[
|
||||||
let g:val = 0
|
let g:val = 0
|
||||||
func! MyHandler(timer)
|
func! MyHandler(timer)
|
||||||
|
while !g:val
|
||||||
|
return
|
||||||
|
endwhile
|
||||||
|
call timer_stop(a:timer)
|
||||||
|
|
||||||
echo "evil"
|
echo "evil"
|
||||||
redraw
|
redraw
|
||||||
let g:val = 1
|
let g:val = 2
|
||||||
endfunc
|
endfunc
|
||||||
]])
|
]])
|
||||||
command("call timer_start(100, 'MyHandler', {'repeat': 1})")
|
command("call timer_start(100, 'MyHandler', {'repeat': -1})")
|
||||||
feed(":good")
|
feed(":good")
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
@@ -237,6 +249,7 @@ describe('timers', function()
|
|||||||
{0:~ }|
|
{0:~ }|
|
||||||
:good^ |
|
:good^ |
|
||||||
]])
|
]])
|
||||||
|
command('let g:val = 1')
|
||||||
|
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
|
|
||||||
@@ -247,6 +260,6 @@ describe('timers', function()
|
|||||||
:good^ |
|
:good^ |
|
||||||
]], intermediate=true, timeout=load_adjust(200)}
|
]], intermediate=true, timeout=load_adjust(200)}
|
||||||
|
|
||||||
eq(1, eval('g:val'))
|
eq(2, eval('g:val'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user