Skip to content

Commit 5c28279

Browse files
committed
Tests: test_terminwscroll_topline2 takes too much time
call a terminal callback function when finished printing, instead of using term_wait(). This causes some timeouts on CI with the macos runners related: vim#16552 Signed-off-by: Christian Brabandt <[email protected]> wait longer Signed-off-by: Christian Brabandt <[email protected]> don't call terminal api on windows
1 parent b08053f commit 5c28279

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/testdir/test_terminal2.vim

+23-16
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,16 @@ func Test_termwinscroll_topline()
290290
endfunc
291291

292292
func Test_termwinscroll_topline2()
293+
" calling the terminal API doesn't work on Windows
294+
CheckNotMSWindows
293295
let g:test_is_flaky = 1
296+
let g:print_complete = 0
297+
func! Tapi_print_complete(bufnum, arglist)
298+
let g:print_complete = 1
299+
endfunc
300+
294301
set termwinscroll=50000 mouse=a
295-
if !has('win32')
296-
set shell=sh
297-
endif
302+
set shell=sh
298303
let norm_winid = win_getid()
299304
terminal
300305
call assert_equal(2, winnr('$'))
@@ -304,26 +309,26 @@ func Test_termwinscroll_topline2()
304309

305310
let num1 = &termwinscroll / 1000 * 999
306311
call writefile(range(num1), 'Xtext', 'D')
307-
if has('win32')
308-
call term_sendkeys(buf, "type Xtext\<CR>")
309-
else
310-
call term_sendkeys(buf, "cat Xtext\<CR>")
311-
endif
312+
call term_sendkeys(buf, "cat Xtext\<CR>")
313+
call term_sendkeys(buf, 'printf ''\033]51;["call", "Tapi_print_complete", []]\007''' .. "\<cr>")
312314
let rows = term_getsize(buf)[0]
313-
" It may take a while to finish on a slow system
314-
call term_wait(buf, 2000 * g:run_nr)
315-
" On MS-Windows there is an empty line, check both last line and above it.
315+
let cnt = 0
316+
while !g:print_complete && cnt <= 1000
317+
" max number of runs
318+
let cnt += 1
319+
" sleep a bit, to give the the terminal some time to finish
320+
321+
" It may take a while to finish on a slow system
322+
" so wait a bit and handle the callback
323+
call term_wait(buf)
324+
endwhile
316325
call WaitForAssert({-> assert_match(string(num1 - 1), term_getline(buf, rows - 1) .. '\|' .. term_getline(buf, rows - 2))})
317326
call feedkeys("\<C-W>N", 'xt')
318327
call feedkeys("i", 'xt')
319328

320329
let num2 = &termwinscroll / 1000 * 8
321330
call writefile(range(num2), 'Xtext', 'D')
322-
if has('win32')
323-
call term_sendkeys(buf, "timeout /t 2 && type Xtext\<CR>")
324-
else
325-
call term_sendkeys(buf, "sleep 2; cat Xtext\<CR>")
326-
endif
331+
call term_sendkeys(buf, "sleep 2; cat Xtext\<CR>")
327332
let winrow = get(get(filter(getwininfo(), 'v:val.winid == norm_winid'), 0, {}), 'winrow', -1)
328333

329334
call test_setmouse(winrow, 1)
@@ -342,6 +347,8 @@ func Test_termwinscroll_topline2()
342347

343348
exe buf . 'bwipe!'
344349
set termwinscroll& mouse& sh&
350+
delfunc Tapi_print_complete
351+
unlet! g:print_complete
345352
endfunc
346353

347354
" Resizing the terminal window caused an ml_get error.

0 commit comments

Comments
 (0)