]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1994: CI: slow cursor positioning may cause flaky test failures v9.1.1994
authorAliaksei Budavei <0x000c70@gmail.com>
Wed, 17 Dec 2025 21:00:49 +0000 (22:00 +0100)
committerChristian Brabandt <cb@256bit.org>
Wed, 17 Dec 2025 21:13:00 +0000 (22:13 +0100)
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 <cb@256bit.org>
src/testdir/util/shared.vim
src/version.c

index ddd3f3725e70d0f55cd6e25fe9245929e223b47b..c49f305debf6eac02d3d04ad75a367cadb323444 100644 (file)
@@ -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()
index ac93ebec0eeb5622c468ff6b82dfc00e34aa62e5..e1b4394909496bb48c204ba298aebaec2852edd1 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1994,
 /**/
     1993,
 /**/