changeset 19898:648752e0d579 v8.2.0505

patch 8.2.0505: term_getty() not sufficiently tested Commit: https://github.com/vim/vim/commit/01603a9970421272621f7c1ecdc560b522c92e61 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 3 12:56:17 2020 +0200 patch 8.2.0505: term_getty() not sufficiently tested Problem: term_getty() not sufficiently tested. Solution: Add more asserts. (Dominique Pelle, closes https://github.com/vim/vim/issues/5877)
author Bram Moolenaar <Bram@vim.org>
date Fri, 03 Apr 2020 13:00:04 +0200
parents 9798325ea060
children eea0515a4e8a
files src/testdir/test_terminal.vim src/version.c
diffstat 2 files changed, 45 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -36,16 +36,6 @@ func Test_terminal_basic()
   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'))
@@ -2186,6 +2176,49 @@ func Test_term_gettitle()
   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
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    505,
+/**/
     504,
 /**/
     503,