From b4901ae0b671fb38467aa609cbf03fbec3ee99ac Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 2 Jul 2026 21:05:39 +0800 Subject: [PATCH] vim-patch:9.2.0392: tests: Some tests are flaky Problem: tests: Some tests are flaky and cause CI to fail Solution: Add WaitForAsserts() calls to reduce flakiness closes: vim/vim#20050 https://github.com/vim/vim/commit/1940bcb243984a2586a4b0b8efb3a8728f6a5b54 Co-authored-by: Christian Brabandt --- test/old/testdir/test_breakindent.vim | 1 + test/old/testdir/test_digraph.vim | 9 +++------ test/old/testdir/test_display.vim | 1 + test/old/testdir/test_edit.vim | 1 + test/old/testdir/test_highlight.vim | 1 + test/old/testdir/test_plugin_matchparen.vim | 1 + test/old/testdir/test_search.vim | 2 ++ test/old/testdir/test_search_stat.vim | 11 +++++++++-- test/old/testdir/test_visual.vim | 4 ++-- 9 files changed, 21 insertions(+), 10 deletions(-) diff --git a/test/old/testdir/test_breakindent.vim b/test/old/testdir/test_breakindent.vim index 3787747104..2413e06733 100644 --- a/test/old/testdir/test_breakindent.vim +++ b/test/old/testdir/test_breakindent.vim @@ -1030,6 +1030,7 @@ func Test_visual_starts_before_skipcol() let buf = RunVimInTerminal('-S XvisualStartsBeforeSkipcol', #{rows: 6}) call term_sendkeys(buf, "v$") + call WaitForAssert({-> assert_match('VISUAL.*\d', term_getline(buf, 6))}, 1000) call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_1', {}) call term_sendkeys(buf, "\:setlocal showbreak=+++\gv") call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_2', {}) diff --git a/test/old/testdir/test_digraph.vim b/test/old/testdir/test_digraph.vim index 0301b210a5..bf83faf7b7 100644 --- a/test/old/testdir/test_digraph.vim +++ b/test/old/testdir/test_digraph.vim @@ -513,14 +513,11 @@ func Test_entering_digraph() CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) call term_sendkeys(buf, "i\") - call TermWait(buf) - call assert_equal('?', term_getline(buf, 1)) + call WaitForAssert({-> assert_equal('?', term_getline(buf, 1))}, 1000) call term_sendkeys(buf, "1") - call TermWait(buf) - call assert_equal('1', term_getline(buf, 1)) + call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))}, 1000) call term_sendkeys(buf, "2") - call TermWait(buf) - call assert_equal('½', term_getline(buf, 1)) + call WaitForAssert({-> assert_equal('½', term_getline(buf, 1))}, 1000) call StopVimInTerminal(buf) endfunc diff --git a/test/old/testdir/test_display.vim b/test/old/testdir/test_display.vim index 032ac14e48..6649456b85 100644 --- a/test/old/testdir/test_display.vim +++ b/test/old/testdir/test_display.vim @@ -263,6 +263,7 @@ func Test_display_scroll_update_visual() let buf = RunVimInTerminal('-S XupdateVisual.vim', #{rows: 8, cols: 60}) call term_sendkeys(buf, "VG7kk") + call WaitForAssert({-> assert_match('VISUAL.*\d\+\s\+\d', term_getline(buf, 8))}, 1000) call VerifyScreenDump(buf, 'Test_display_scroll_update_visual', {}) call StopVimInTerminal(buf) diff --git a/test/old/testdir/test_edit.vim b/test/old/testdir/test_edit.vim index d48a8e6fca..cb78086bcb 100644 --- a/test/old/testdir/test_edit.vim +++ b/test/old/testdir/test_edit.vim @@ -2087,6 +2087,7 @@ func Test_edit_ctrl_r_failed() " trying to insert a blob produces an error call term_sendkeys(buf, "i\=0z\") + call WaitForAssert({-> assert_match('^E976:', term_getline(buf, 5))}, 1000) " ending Insert mode should put the cursor back on the ':' call term_sendkeys(buf, ":\") diff --git a/test/old/testdir/test_highlight.vim b/test/old/testdir/test_highlight.vim index 1882ccfc90..b236ee5b9a 100644 --- a/test/old/testdir/test_highlight.vim +++ b/test/old/testdir/test_highlight.vim @@ -775,6 +775,7 @@ func Test_visual_sbr() let buf = RunVimInTerminal('-S Xtest_visual_sbr', {'rows': 6,'columns': 60}) call term_sendkeys(buf, "v$") + call WaitForAssert({-> assert_match('VISUAL.*\d\+\s\+\d', term_getline(buf, 6))}, 1000) call VerifyScreenDump(buf, 'Test_visual_sbr_1', {}) " clean up diff --git a/test/old/testdir/test_plugin_matchparen.vim b/test/old/testdir/test_plugin_matchparen.vim index 684d97a428..506cfc38cf 100644 --- a/test/old/testdir/test_plugin_matchparen.vim +++ b/test/old/testdir/test_plugin_matchparen.vim @@ -25,6 +25,7 @@ func Test_visual_block_scroll() let buf = RunVimInTerminal('-S '.filename, #{rows: 7}) call term_sendkeys(buf, "V\\") + call WaitForAssert({-> assert_match('VISUAL.*\d\+\s\+\d', term_getline(buf, 7))}, 1000) call VerifyScreenDump(buf, 'Test_display_visual_block_scroll', {}) call StopVimInTerminal(buf) diff --git a/test/old/testdir/test_search.vim b/test/old/testdir/test_search.vim index 3fecb84108..8f883916ff 100644 --- a/test/old/testdir/test_search.vim +++ b/test/old/testdir/test_search.vim @@ -995,6 +995,7 @@ func Test_hlsearch_and_visual() \ ], 'Xhlvisual_script', 'D') let buf = RunVimInTerminal('-S Xhlvisual_script', {'rows': 6, 'cols': 40}) call term_sendkeys(buf, "vjj") + call WaitForAssert({-> assert_match('VISUAL.*-\d', term_getline(buf, 6))}, 1000) call VerifyScreenDump(buf, 'Test_hlsearch_visual_1', {}) call term_sendkeys(buf, "\") @@ -2119,6 +2120,7 @@ func Test_incsearch_highlighting_newline() [CODE] call writefile(commands, 'Xincsearch_nl', 'D') let buf = RunVimInTerminal('-S Xincsearch_nl', {'rows': 5, 'cols': 10}) + call TermWait(buf, 100) call term_sendkeys(buf, '/test') call VerifyScreenDump(buf, 'Test_incsearch_newline1', {}) " Need to send one key at a time to force a redraw diff --git a/test/old/testdir/test_search_stat.vim b/test/old/testdir/test_search_stat.vim index b741b34506..495e498cb8 100644 --- a/test/old/testdir/test_search_stat.vim +++ b/test/old/testdir/test_search_stat.vim @@ -412,16 +412,23 @@ func Test_search_stat_and_incsearch() call writefile(lines, 'Xsearchstat_inc', 'D') let buf = RunVimInTerminal('-S Xsearchstat_inc', #{rows: 10}) + call TermWait(buf, 100) call term_sendkeys(buf, "/abc") call TermWait(buf) + " The first 3 chars on line 2 should have highlighting, but the following not + " So assert the attr value of those 4 chars + call WaitForAssert({-> assert_true( + \ term_scrape(buf, 2)[0].attr == term_scrape(buf, 2)[1].attr && + \ term_scrape(buf, 2)[1].attr == term_scrape(buf, 2)[2].attr && + \ term_scrape(buf, 2)[2].attr != term_scrape(buf, 2)[3].attr)}, 1000) call VerifyScreenDump(buf, 'Test_searchstat_inc_1', {}) call term_sendkeys(buf, "\") - call TermWait(buf) + call WaitForAssert({-> assert_match('^3', term_getline(buf, 1))}, 1000) call VerifyScreenDump(buf, 'Test_searchstat_inc_2', {}) call term_sendkeys(buf, "\") - call TermWait(buf) + call WaitForAssert({-> assert_match('^1', term_getline(buf, 1))}, 1000) call VerifyScreenDump(buf, 'Test_searchstat_inc_3', {}) call term_sendkeys(buf, "\:qa\") diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim index 9d663256cb..25cef0aab6 100644 --- a/test/old/testdir/test_visual.vim +++ b/test/old/testdir/test_visual.vim @@ -1321,10 +1321,11 @@ func Test_visual_block_with_virtualedit() set virtualedit=block normal G END - call writefile(lines, 'XTest_block') + call writefile(lines, 'XTest_block', 'D') let buf = RunVimInTerminal('-S XTest_block', {'rows': 8, 'cols': 50}) call term_sendkeys(buf, "\gg$") + call WaitForAssert({-> assert_match('VISUAL.*\dx\d', term_getline(buf, 8))}, 1000) call VerifyScreenDump(buf, 'Test_visual_block_with_virtualedit', {}) call term_sendkeys(buf, "\gg\G$") @@ -1333,7 +1334,6 @@ func Test_visual_block_with_virtualedit() " clean up call term_sendkeys(buf, "\") call StopVimInTerminal(buf) - call delete('XTest_block') endfunc func Test_visual_block_ctrl_w_f()