From: Aliaksei Budavei <0x000c70@gmail.com> Date: Wed, 17 Dec 2025 21:00:49 +0000 (+0100) Subject: patch 9.1.1994: CI: slow cursor positioning may cause flaky test failures X-Git-Tag: v9.1.1994^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ac778723b0e2817d1e6e19961c626169b001a68;p=thirdparty%2Fvim.git patch 9.1.1994: CI: slow cursor positioning may cause flaky test failures Problem: More deterministic synchronisation can be established between processes running test cases and collecting visual effects to a screendump file for future verification by anticipating the availability of known parts of such a file and asserting the location of the cursor. Solution: Provide a convenience test function that waits a specified time for cursor positioning (Aliaksei Budavei) related: #18920 Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt --- diff --git a/src/testdir/util/shared.vim b/src/testdir/util/shared.vim index ddd3f3725e..c49f305deb 100644 --- a/src/testdir/util/shared.vim +++ b/src/testdir/util/shared.vim @@ -164,6 +164,30 @@ func WaitForChildNotification(...) let g:child_notification = 0 endfunc +" Wait for the cursor position in a terminal buffer to fall in range and for +" specific line contents to be matchable against expected patterns. +" +" The waited-for cursor position [lnum, cnum] can be discovered by searching +" for the only instance of non-"|"-delimited ">" in an already verified +" screendump file, with every "|.\+|" cell entry counted as a single column. +" Use 2-tuples (aka pairs) with (lnum, pattern) as optional arguments for +" additional points of synchronisation. Assuming that buffer lines are drawn +" from top to bottom, consider pairing up the bottom line number with its +" corresponding whole line pattern; if nothing will be written on the bottom +" line, or if other lines will be further updated before verification, then +" prefer a more recently-updated line (or lines) for matching. +func WaitForTermCurPosAndLinesToMatch(bnum, cpos, timeout = g:test_timeout, ...) + if empty(term_getstatus(a:bnum)) + throw 'Skipped: Not a terminal buffer' + endif + + if a:0 > 0 && indexof(a:000, {_, ps -> len(ps) != 2}) < 0 + return WaitFor({b, c, ps -> {-> slice(term_getcursor(b), 0, 2) == c && indexof(ps, {b_ -> {_, p -> term_getline(b_, p[0]) !~# p[1]}}(b)) < 0}}(a:bnum, a:cpos, a:000), a:timeout) + else + return WaitFor({b, c -> {-> slice(term_getcursor(b), 0, 2) == c}}(a:bnum, a:cpos), a:timeout) + endif +endfunc + " Wait for up to five seconds for "expr" to become true. "expr" can be a " stringified expression to evaluate, or a funcref without arguments. " Using a lambda works best. Example: @@ -354,6 +378,8 @@ func ValgrindOrAsan() return RunningWithValgrind() || RunningAsan() endfun +const g:test_timeout = (ValgrindOrAsan()) ? 5000 * 4 : 5000 + " Get the command to run Vim, with --clean instead of "-u NONE". func GetVimCommandClean() let cmd = GetVimCommand() diff --git a/src/version.c b/src/version.c index ac93ebec0e..e1b4394909 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1994, /**/ 1993, /**/