]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0396: tests: Test_error_callback_terminal is flaky on macOS v9.2.0396
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Sun, 26 Apr 2026 09:22:38 +0000 (09:22 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 26 Apr 2026 09:22:38 +0000 (09:22 +0000)
Problem:  tests: Test_error_callback_terminal is flaky on macOS
Solution: Use WaitForAssert() to make it more reliable
          (Yasuhiro Matsumoto).

term_wait() only waits for terminal screen updates and does not
guarantee that the err_io 'pipe' callback has fired, so on macOS
the assert_match() against g:error frequently runs before sh has
written "sh: XXXX: not found", causing the test to flake.

Replace term_wait() + assert_match() with WaitForAssert() so each
assertion polls until the callback delivers the expected output.
Also defer sending "exit" until the stderr message has been seen,
to avoid losing the stderr write to the exit race.

closes: #20075

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_channel.vim
src/version.c

index 23f8a0fc3e3eff243f654288a69aca4d9ca47c62..ceb553263770a8f3e47c349f38a8039547e8a776 100644 (file)
@@ -2922,11 +2922,11 @@ func Test_error_callback_terminal()
   call assert_equal('RAW', dict.err_mode)
   call assert_equal('pipe', dict.err_io)
   call term_sendkeys(buf, "XXXX\<cr>")
-  call term_wait(buf)
+  " term_wait() does not wait for the err_io 'pipe' callback to fire, so use
+  " WaitForAssert() to poll until sh has written the error message.
+  call WaitForAssert({-> assert_match('sh:.*XXXX:.*not found', g:error)}, 5000)
   call term_sendkeys(buf, "exit\<cr>")
-  call term_wait(buf)
-  call assert_match('XXX.*exit', g:out)
-  call assert_match('sh:.*XXXX:.*not found', g:error)
+  call WaitForAssert({-> assert_match('XXX.*exit', g:out)}, 5000)
 
   delfunc s:Out
   delfunc s:Err
index 369938147f7d54f6818dccad9c68336ee3c4f560..e714ddc2a3cc1935f1bbbaf830d715e2774a7fb8 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    396,
 /**/
     395,
 /**/