From cf3b871fa940c42e9c94257118f7d1131ebd362a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Aug 2022 15:21:46 +0800 Subject: 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. --- test/functional/editor/ctrl_c_spec.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'test/functional/editor/ctrl_c_spec.lua') diff --git a/test/functional/editor/ctrl_c_spec.lua b/test/functional/editor/ctrl_c_spec.lua index 60131bf2a4..4548e1aa34 100644 --- a/test/functional/editor/ctrl_c_spec.lua +++ b/test/functional/editor/ctrl_c_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, source = helpers.clear, helpers.feed, helpers.source local command = helpers.command +local poke_eventloop = helpers.poke_eventloop local sleep = helpers.sleep describe("CTRL-C (mapped)", function() @@ -57,11 +58,9 @@ describe("CTRL-C (mapped)", function() it('interrupts :sleep', function() command('nnoremap ') feed(':sleep 100') - -- wait for :sleep to start - sleep(10) + poke_eventloop() -- wait for :sleep to start feed('foo') - -- wait for input buffer to be flushed - sleep(10) + poke_eventloop() -- wait for input buffer to be flushed feed('i') screen:expect([[ ^ | @@ -77,10 +76,9 @@ describe("CTRL-C (mapped)", function() command('nnoremap ') command('nmap ') feed('') - sleep(10) + sleep(10) -- wait for the key to enter typeahead feed('foo') - -- wait for input buffer to be flushed - sleep(10) + poke_eventloop() -- wait for input buffer to be flushed feed('i') screen:expect([[ ^ | -- cgit