To: vim_dev@googlegroups.com Subject: Patch 8.0.1605 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1605 Problem: Terminal test is a bit flaky. Solution: Check for the shell prompt. Use more lambda functions. Files: src/testdir/test_terminal.vim *** ../vim-8.0.1604/src/testdir/test_terminal.vim 2018-03-11 16:55:30.008616433 +0100 --- src/testdir/test_terminal.vim 2018-03-13 17:52:23.350725108 +0100 *************** *** 432,470 **** if !has('clientserver') return endif ! let g:buf = Run_shell_in_terminal({}) " Wait for the shell to display a prompt ! call WaitFor('term_getline(g:buf, 1) != ""') if has('win32') ! call term_sendkeys(g:buf, "echo %VIM_SERVERNAME%\r") else ! call term_sendkeys(g:buf, "echo $VIM_SERVERNAME\r") endif ! call term_wait(g:buf) ! call Stop_shell_in_terminal(g:buf) call WaitFor('getline(2) == v:servername') call assert_equal(v:servername, getline(2)) ! exe g:buf . 'bwipe' ! unlet g:buf endfunc func Test_terminal_env() ! let g:buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}}) " Wait for the shell to display a prompt ! call WaitFor('term_getline(g:buf, 1) != ""') if has('win32') ! call term_sendkeys(g:buf, "echo %TESTENV%\r") else ! call term_sendkeys(g:buf, "echo $TESTENV\r") endif ! call term_wait(g:buf) ! call Stop_shell_in_terminal(g:buf) call WaitFor('getline(2) == "correct"') call assert_equal('correct', getline(2)) ! exe g:buf . 'bwipe' ! unlet g:buf endfunc " must be last, we can't go back from GUI to terminal --- 432,469 ---- if !has('clientserver') return endif ! let buf = Run_shell_in_terminal({}) " Wait for the shell to display a prompt ! call WaitFor({-> term_getline(buf, 1) != ""}) if has('win32') ! call term_sendkeys(buf, "echo %VIM_SERVERNAME%\r") else ! call term_sendkeys(buf, "echo $VIM_SERVERNAME\r") endif ! call term_wait(buf) ! call Stop_shell_in_terminal(buf) call WaitFor('getline(2) == v:servername') call assert_equal(v:servername, getline(2)) ! exe buf . 'bwipe' ! unlet buf endfunc func Test_terminal_env() ! let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}}) " Wait for the shell to display a prompt ! call WaitFor({-> term_getline(buf, 1) != ""}) if has('win32') ! call term_sendkeys(buf, "echo %TESTENV%\r") else ! call term_sendkeys(buf, "echo $TESTENV\r") endif ! call term_wait(buf) ! call Stop_shell_in_terminal(buf) call WaitFor('getline(2) == "correct"') call assert_equal('correct', getline(2)) ! exe buf . 'bwipe' endfunc " must be last, we can't go back from GUI to terminal *************** *** 591,598 **** else call system('echo "look here" > ' . pty) endif ! let g:buf = buf ! call WaitFor('term_getline(g:buf, 1) =~ "look here"') call assert_match('look here', term_getline(buf, 1)) bwipe! --- 590,596 ---- else call system('echo "look here" > ' . pty) endif ! call WaitFor({-> term_getline(buf, 1) =~ "look here"}) call assert_match('look here', term_getline(buf, 1)) bwipe! *************** *** 672,679 **** call assert_equal('456', maparg('123', 't')) call assert_equal('abxde', maparg('456', 't')) call feedkeys("123", 'tx') ! let g:buf = buf ! call WaitFor("term_getline(g:buf,term_getcursor(g:buf)[0]) =~ 'abxde\\|456'") let lnum = term_getcursor(buf)[0] if a:remap call assert_match('abxde', term_getline(buf, lnum)) --- 670,676 ---- call assert_equal('456', maparg('123', 't')) call assert_equal('abxde', maparg('456', 't')) call feedkeys("123", 'tx') ! call WaitFor({-> term_getline(buf, term_getcursor(buf)[0]) =~ 'abxde\|456'}) let lnum = term_getcursor(buf)[0] if a:remap call assert_match('abxde', term_getline(buf, lnum)) *************** *** 816,827 **** endif let buf = Run_shell_in_terminal({}) ! call term_wait(buf) ! new ! call setline(1, "\x1b[6n") ! write! Xescape ! bwipe call term_sendkeys(buf, "cat Xescape\") " wait for the response of control sequence from libvterm (and send it to tty) --- 813,821 ---- endif let buf = Run_shell_in_terminal({}) ! call WaitFor({-> term_getline(buf, 1) != ""}) ! call writefile(["\x1b[6n"], 'Xescape') call term_sendkeys(buf, "cat Xescape\") " wait for the response of control sequence from libvterm (and send it to tty) *************** *** 909,915 **** quit endfunc ! func Test_terminalopen_autocmd() augroup repro au! au TerminalOpen * let s:called += 1 --- 903,909 ---- quit endfunc ! func Test_terminal_open_autocmd() augroup repro au! au TerminalOpen * let s:called += 1 *** ../vim-8.0.1604/src/version.c 2018-03-13 15:43:43.108617291 +0100 --- src/version.c 2018-03-13 17:53:37.494281169 +0100 *************** *** 768,769 **** --- 768,771 ---- { /* Add new patch number below this line */ + /**/ + 1605, /**/ -- The goal of science is to build better mousetraps. The goal of nature is to build better mice. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///