From: Hirohito Higashi Date: Wed, 12 Aug 2026 21:40:50 +0000 (+0000) Subject: patch 9.2.0955: tests: terminal tests are flaky X-Git-Tag: v9.2.0955^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fa96c9ea30f5679e91fef54a2181af8a65ba9ba5;p=thirdparty%2Fvim.git patch 9.2.0955: tests: terminal tests are flaky Problem: Test_terminal_aucmd_on_close() is flaky on MS-Windows: the tests that wait for a terminal window to close use a timeout shorter than the default, which is not enough when starting a process is slow. When the wait fails the test aborts with E121 and leaves an autocommand behind for the following tests. Test_terminal_unwraps() checks the buffer contents without waiting for the job to finish. Solution: Use the default timeout of WaitForAssert(), initialize the variable checked after the wait, and wait for the buffer to hold the unwrapped line. closes: #21039 Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 096904e111..706fb1ebca 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -692,24 +692,21 @@ endfunc func s:get_sleep_cmd() if s:python != '' let cmd = s:python . " test_short_sleep.py" - " 500 was not enough for Travis - let waittime = 900 else echo 'This will take five seconds...' - let waittime = 2000 if has('win32') let cmd = $windir . '\system32\timeout.exe 1' else let cmd = 'sleep 1' endif endif - return [cmd, waittime] + return cmd endfunc func Test_terminal_finish_open_close() call assert_equal(1, winnr('$')) - let [cmd, waittime] = s:get_sleep_cmd() + let cmd = s:get_sleep_cmd() " shell terminal closes automatically terminal @@ -718,7 +715,7 @@ func Test_terminal_finish_open_close() " Wait for the shell to display a prompt call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))}) call StopShellInTerminal(buf) - call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(1, winnr('$'))}) " shell terminal that does not close automatically terminal ++noclose @@ -734,32 +731,32 @@ func Test_terminal_finish_open_close() exe 'terminal ++close ' . cmd call assert_equal(2, winnr('$')) wincmd p - call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(1, winnr('$'))}) call term_start(cmd, {'term_finish': 'close'}) call assert_equal(2, winnr('$')) wincmd p - call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(1, winnr('$'))}) call assert_equal(1, winnr('$')) exe 'terminal ++open ' . cmd close! - call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(2, winnr('$'))}) bwipe call term_start(cmd, {'term_finish': 'open'}) close! - call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(2, winnr('$'))}) bwipe exe 'terminal ++hidden ++open ' . cmd call assert_equal(1, winnr('$')) - call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(2, winnr('$'))}) bwipe call term_start(cmd, {'term_finish': 'open', 'hidden': 1}) call assert_equal(1, winnr('$')) - call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(2, winnr('$'))}) bwipe call assert_fails("call term_start(cmd, {'term_opencmd': 'open'})", 'E475:') @@ -769,7 +766,7 @@ func Test_terminal_finish_open_close() call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d | let g:result = "opened the buffer in a window"'}) close! - call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(2, winnr('$'))}) call assert_equal(4, winheight(0)) call assert_equal('opened the buffer in a window', g:result) unlet g:result @@ -1233,6 +1230,7 @@ func Test_terminal_composing_unicode() endfunc func Test_terminal_aucmd_on_close() + let s:called = 0 fun Nop() let s:called = 1 endfun @@ -1242,14 +1240,14 @@ func Test_terminal_aucmd_on_close() au BufWinLeave * call Nop() aug END - let [cmd, waittime] = s:get_sleep_cmd() + let cmd = s:get_sleep_cmd() call assert_equal(1, winnr('$')) new call setline(1, ['one', 'two']) exe 'term ++close ' . cmd wincmd p - call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime) + call WaitForAssert({-> assert_equal(2, winnr('$'))}) call assert_equal(1, s:called) bwipe! @@ -2498,9 +2496,10 @@ func Test_terminal_unwraps() call assert_equal('14+15', l) call TermWait(buf) - " It should appear as a single buffer line in vim - let lastline = getline('$') - call assert_equal('1+2+3+4+5+6+7+8+9+10+11+12+13+14+15', lastline) + " It should appear as a single buffer line in vim, once the job finished and + " the contents were moved to the buffer. + call WaitForAssert({-> assert_equal( + \ '1+2+3+4+5+6+7+8+9+10+11+12+13+14+15', getline('$'))}) bwipe! endfunc diff --git a/src/version.c b/src/version.c index 1955674ae6..4a6e48ce48 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 955, /**/ 954, /**/