test: use poke_eventloop() instead of sleep(10) where possible (#19794)

Using sleep(10) to wait for typeahead to finish is flaky, especially on
macOS, where legacy/global_spec.lua has failed several times.
This commit is contained in:
zeertzjq
2022-08-16 15:21:46 +08:00
committed by GitHub
parent a63eea3d23
commit cf3b871fa9
4 changed files with 19 additions and 21 deletions

View File

@@ -131,11 +131,11 @@ describe('mapping', function()
command('set selectmode=mouse')
command('nnoremap <LeftDrag> <LeftDrag><Cmd><CR>')
sleep(10)
poke_eventloop()
meths.input_mouse('left', 'press', '', 0, 0, 0)
sleep(10)
poke_eventloop()
meths.input_mouse('left', 'drag', '', 0, 0, 1)
sleep(10)
poke_eventloop()
eq('s', eval('mode()'))
end)
@@ -144,22 +144,22 @@ describe('mapping', function()
command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>')
feed('i')
sleep(10)
poke_eventloop()
meths.input_mouse('left', 'press', '', 0, 0, 0)
sleep(10)
poke_eventloop()
meths.input_mouse('left', 'drag', '', 0, 0, 1)
sleep(10)
poke_eventloop()
eq(1, eval('g:dragged'))
eq('v', eval('mode()'))
feed([[<C-\><C-N>]])
command([[inoremap <LeftDrag> <LeftDrag><C-\><C-N>]])
feed('i')
sleep(10)
poke_eventloop()
meths.input_mouse('left', 'press', '', 0, 0, 0)
sleep(10)
poke_eventloop()
meths.input_mouse('left', 'drag', '', 0, 0, 1)
sleep(10)
poke_eventloop()
eq('n', eval('mode()'))
end)