To: vim_dev@googlegroups.com Subject: Patch 8.2.0505 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0505 Problem: term_getty() not sufficiently tested. Solution: Add more asserts. (Dominique Pelle, closes #5877) Files: src/testdir/test_terminal.vim *** ../vim-8.2.0504/src/testdir/test_terminal.vim 2020-03-30 19:38:40.463266669 +0200 --- src/testdir/test_terminal.vim 2020-04-03 12:54:10.047527137 +0200 *************** *** 36,51 **** au TerminalOpen * let b:done = 'yes' let buf = Run_shell_in_terminal({}) - if has("unix") - call assert_match('^/dev/', job_info(g:job).tty_out) - call assert_match('^/dev/', term_gettty('')) - else - " ConPTY works on anonymous pipe. - if !has('conpty') - call assert_match('^\\\\.\\pipe\\', job_info(g:job).tty_out) - call assert_match('^\\\\.\\pipe\\', ''->term_gettty()) - endif - endif call assert_equal('t', mode()) call assert_equal('yes', b:done) call assert_match('%aR[^\n]*running]', execute('ls')) --- 36,41 ---- *************** *** 2186,2191 **** --- 2176,2224 ---- exe term . 'bwipe!' endfunc + func Test_term_gettty() + let buf = Run_shell_in_terminal({}) + let gettty = term_gettty(buf) + + if has('unix') && executable('tty') + " Find tty using the tty shell command. + call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))}) + call term_sendkeys(buf, "tty\r") + call WaitForAssert({-> assert_notequal('', term_getline(buf, 3))}) + let tty = term_getline(buf, 2) + call assert_equal(tty, gettty) + endif + + let gettty0 = term_gettty(buf, 0) + let gettty1 = term_gettty(buf, 1) + + call assert_equal(gettty, gettty0) + call assert_equal(job_info(g:job).tty_out, gettty0) + call assert_equal(job_info(g:job).tty_in, gettty1) + + if has('unix') + " For unix, term_gettty(..., 0) and term_gettty(..., 1) + " are identical according to :help term_gettty() + call assert_equal(gettty0, gettty1) + call assert_match('^/dev/', gettty) + else + " ConPTY works on anonymous pipe. + if !has('conpty') + call assert_match('^\\\\.\\pipe\\', gettty0) + call assert_match('^\\\\.\\pipe\\', gettty1) + endif + endif + + call assert_fails('call term_gettty(buf, 2)', 'E475:') + call assert_fails('call term_gettty(buf, -1)', 'E475:') + + call assert_equal('', term_gettty(buf + 1)) + + call StopShellInTerminal(buf) + call term_wait(buf) + exe buf . 'bwipe' + endfunc + " When drawing the statusline the cursor position may not have been updated " yet. " 1. create a terminal, make it show 2 lines *** ../vim-8.2.0504/src/version.c 2020-04-02 22:57:32.331945116 +0200 --- src/version.c 2020-04-03 12:55:10.519364397 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 505, /**/ -- VOICE OVER: As the horrendous Black Beast lunged forward, escape for Arthur and his knights seemed hopeless, when, suddenly ... the animator suffered a fatal heart attack. ANIMATOR: Aaaaagh! VOICE OVER: The cartoon peril was no more ... The Quest for Holy Grail could continue. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///