Commit: patch 9.1.1994: CI: slow cursor positioning may cause flaky test failures

1 view
Skip to first unread message

Christian Brabandt

unread,
Dec 17, 2025, 4:15:51 PM (10 hours ago) Dec 17
to vim...@googlegroups.com
patch 9.1.1994: CI: slow cursor positioning may cause flaky test failures

Commit: https://github.com/vim/vim/commit/6ac778723b0e2817d1e6e19961c626169b001a68
Author: Aliaksei Budavei <0x00...@gmail.com>
Date: Wed Dec 17 22:00:49 2025 +0100

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 <0x00...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/testdir/util/shared.vim b/src/testdir/util/shared.vim
index ddd3f3725..c49f305de 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 ac93ebec0..e1b439490 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,
/**/
Reply all
Reply to author
Forward
0 new messages