Skip to content

Commit 012eb66

Browse files
committed
patch 8.0.1605: terminal test is a bit flaky
Problem: Terminal test is a bit flaky. Solution: Check for the shell prompt. Use more lambda functions.
1 parent a903472 commit 012eb66

2 files changed

Lines changed: 22 additions & 26 deletions

File tree

src/testdir/test_terminal.vim

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -432,39 +432,38 @@ func Test_terminal_servername()
432432
if !has('clientserver')
433433
return
434434
endif
435-
let g:buf = Run_shell_in_terminal({})
435+
let buf = Run_shell_in_terminal({})
436436
" Wait for the shell to display a prompt
437-
call WaitFor('term_getline(g:buf, 1) != ""')
437+
call WaitFor({-> term_getline(buf, 1) != ""})
438438
if has('win32')
439-
call term_sendkeys(g:buf, "echo %VIM_SERVERNAME%\r")
439+
call term_sendkeys(buf, "echo %VIM_SERVERNAME%\r")
440440
else
441-
call term_sendkeys(g:buf, "echo $VIM_SERVERNAME\r")
441+
call term_sendkeys(buf, "echo $VIM_SERVERNAME\r")
442442
endif
443-
call term_wait(g:buf)
444-
call Stop_shell_in_terminal(g:buf)
443+
call term_wait(buf)
444+
call Stop_shell_in_terminal(buf)
445445
call WaitFor('getline(2) == v:servername')
446446
call assert_equal(v:servername, getline(2))
447447

448-
exe g:buf . 'bwipe'
449-
unlet g:buf
448+
exe buf . 'bwipe'
449+
unlet buf
450450
endfunc
451451

452452
func Test_terminal_env()
453-
let g:buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}})
453+
let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}})
454454
" Wait for the shell to display a prompt
455-
call WaitFor('term_getline(g:buf, 1) != ""')
455+
call WaitFor({-> term_getline(buf, 1) != ""})
456456
if has('win32')
457-
call term_sendkeys(g:buf, "echo %TESTENV%\r")
457+
call term_sendkeys(buf, "echo %TESTENV%\r")
458458
else
459-
call term_sendkeys(g:buf, "echo $TESTENV\r")
459+
call term_sendkeys(buf, "echo $TESTENV\r")
460460
endif
461-
call term_wait(g:buf)
462-
call Stop_shell_in_terminal(g:buf)
461+
call term_wait(buf)
462+
call Stop_shell_in_terminal(buf)
463463
call WaitFor('getline(2) == "correct"')
464464
call assert_equal('correct', getline(2))
465465

466-
exe g:buf . 'bwipe'
467-
unlet g:buf
466+
exe buf . 'bwipe'
468467
endfunc
469468

470469
" must be last, we can't go back from GUI to terminal
@@ -591,8 +590,7 @@ func Test_terminal_no_cmd()
591590
else
592591
call system('echo "look here" > ' . pty)
593592
endif
594-
let g:buf = buf
595-
call WaitFor('term_getline(g:buf, 1) =~ "look here"')
593+
call WaitFor({-> term_getline(buf, 1) =~ "look here"})
596594

597595
call assert_match('look here', term_getline(buf, 1))
598596
bwipe!
@@ -672,8 +670,7 @@ func TerminalTmap(remap)
672670
call assert_equal('456', maparg('123', 't'))
673671
call assert_equal('abxde', maparg('456', 't'))
674672
call feedkeys("123", 'tx')
675-
let g:buf = buf
676-
call WaitFor("term_getline(g:buf,term_getcursor(g:buf)[0]) =~ 'abxde\\|456'")
673+
call WaitFor({-> term_getline(buf, term_getcursor(buf)[0]) =~ 'abxde\|456'})
677674
let lnum = term_getcursor(buf)[0]
678675
if a:remap
679676
call assert_match('abxde', term_getline(buf, lnum))
@@ -816,12 +813,9 @@ func Test_terminal_response_to_control_sequence()
816813
endif
817814

818815
let buf = Run_shell_in_terminal({})
819-
call term_wait(buf)
816+
call WaitFor({-> term_getline(buf, 1) != ""})
820817

821-
new
822-
call setline(1, "\x1b[6n")
823-
write! Xescape
824-
bwipe
818+
call writefile(["\x1b[6n"], 'Xescape')
825819
call term_sendkeys(buf, "cat Xescape\<cr>")
826820

827821
" wait for the response of control sequence from libvterm (and send it to tty)
@@ -909,7 +903,7 @@ func Test_terminal_qall_prompt()
909903
quit
910904
endfunc
911905

912-
func Test_terminalopen_autocmd()
906+
func Test_terminal_open_autocmd()
913907
augroup repro
914908
au!
915909
au TerminalOpen * let s:called += 1

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ static char *(features[]) =
766766

767767
static int included_patches[] =
768768
{ /* Add new patch number below this line */
769+
/**/
770+
1605,
769771
/**/
770772
1604,
771773
/**/

0 commit comments

Comments
 (0)