From aae1bfbdb96ccbbf5314321849b5f384a3d7c6a0 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Sun, 9 Feb 2025 17:10:30 +0100 Subject: [PATCH] patch 9.1.1090: tests: test_terminwscroll_topline2 unreliable Problem: tests: test_terminwscroll_topline2 unreliable (Yee Cheng Chin) Solution: instead of using term_wait() with a specific time, use terminal-api and to wait until the terminal is finished call a terminal callback function when finished printing, instead of using term_wait(), with a defined time, which caused timeouts on CI with the macos runners Unfortunately I couldn't figure out how to call the terminal-api on Windows, so skip the test on Windows. cmd.com echo didn's seem to work and neither did trying to use python, but perhaps it was just me fighting with the terminal quoting rules :shrug: related: #16599 related: #16552 Signed-off-by: Christian Brabandt --- src/testdir/test_terminal2.vim | 39 ++++++++++++++++++++-------------- src/version.c | 2 ++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/testdir/test_terminal2.vim b/src/testdir/test_terminal2.vim index c6edea99a0..5c4563ccf7 100644 --- a/src/testdir/test_terminal2.vim +++ b/src/testdir/test_terminal2.vim @@ -290,11 +290,16 @@ func Test_termwinscroll_topline() endfunc func Test_termwinscroll_topline2() + " calling the terminal API doesn't work on Windows + CheckNotMSWindows let g:test_is_flaky = 1 + let g:print_complete = 0 + func! Tapi_print_complete(bufnum, arglist) + let g:print_complete = 1 + endfunc + set termwinscroll=50000 mouse=a - if !has('win32') - set shell=sh - endif + set shell=sh let norm_winid = win_getid() terminal call assert_equal(2, winnr('$')) @@ -304,26 +309,26 @@ func Test_termwinscroll_topline2() let num1 = &termwinscroll / 1000 * 999 call writefile(range(num1), 'Xtext', 'D') - if has('win32') - call term_sendkeys(buf, "type Xtext\") - else - call term_sendkeys(buf, "cat Xtext\") - endif + call term_sendkeys(buf, "cat Xtext\") + call term_sendkeys(buf, 'printf ''\033]51;["call", "Tapi_print_complete", []]\007''' .. "\") let rows = term_getsize(buf)[0] - " It may take a while to finish on a slow system - call term_wait(buf, 2000 * g:run_nr) - " On MS-Windows there is an empty line, check both last line and above it. + let cnt = 0 + while !g:print_complete && cnt <= 1000 + " max number of runs + let cnt += 1 + " sleep a bit, to give the the terminal some time to finish + + " It may take a while to finish on a slow system + " so wait a bit and handle the callback + call term_wait(buf) + endwhile call WaitForAssert({-> assert_match(string(num1 - 1), term_getline(buf, rows - 1) .. '\|' .. term_getline(buf, rows - 2))}) call feedkeys("\N", 'xt') call feedkeys("i", 'xt') let num2 = &termwinscroll / 1000 * 8 call writefile(range(num2), 'Xtext', 'D') - if has('win32') - call term_sendkeys(buf, "timeout /t 2 && type Xtext\") - else - call term_sendkeys(buf, "sleep 2; cat Xtext\") - endif + call term_sendkeys(buf, "sleep 2; cat Xtext\") let winrow = get(get(filter(getwininfo(), 'v:val.winid == norm_winid'), 0, {}), 'winrow', -1) call test_setmouse(winrow, 1) @@ -342,6 +347,8 @@ func Test_termwinscroll_topline2() exe buf . 'bwipe!' set termwinscroll& mouse& sh& + delfunc Tapi_print_complete + unlet! g:print_complete endfunc " Resizing the terminal window caused an ml_get error. diff --git a/src/version.c b/src/version.c index 28234de1a7..580f82a0b6 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1090, /**/ 1089, /**/ -- 2.47.2