Skip to content

Commit 01603a9

Browse files
committed
patch 8.2.0505: term_getty() not sufficiently tested
Problem: term_getty() not sufficiently tested. Solution: Add more asserts. (Dominique Pelle, closes #5877)
1 parent 3cca299 commit 01603a9

2 files changed

Lines changed: 45 additions & 10 deletions

File tree

src/testdir/test_terminal.vim

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ func Test_terminal_basic()
3636
au TerminalOpen * let b:done = 'yes'
3737
let buf = Run_shell_in_terminal({})
3838

39-
if has("unix")
40-
call assert_match('^/dev/', job_info(g:job).tty_out)
41-
call assert_match('^/dev/', term_gettty(''))
42-
else
43-
" ConPTY works on anonymous pipe.
44-
if !has('conpty')
45-
call assert_match('^\\\\.\\pipe\\', job_info(g:job).tty_out)
46-
call assert_match('^\\\\.\\pipe\\', ''->term_gettty())
47-
endif
48-
endif
4939
call assert_equal('t', mode())
5040
call assert_equal('yes', b:done)
5141
call assert_match('%aR[^\n]*running]', execute('ls'))
@@ -2186,6 +2176,49 @@ func Test_term_gettitle()
21862176
exe term . 'bwipe!'
21872177
endfunc
21882178

2179+
func Test_term_gettty()
2180+
let buf = Run_shell_in_terminal({})
2181+
let gettty = term_gettty(buf)
2182+
2183+
if has('unix') && executable('tty')
2184+
" Find tty using the tty shell command.
2185+
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
2186+
call term_sendkeys(buf, "tty\r")
2187+
call WaitForAssert({-> assert_notequal('', term_getline(buf, 3))})
2188+
let tty = term_getline(buf, 2)
2189+
call assert_equal(tty, gettty)
2190+
endif
2191+
2192+
let gettty0 = term_gettty(buf, 0)
2193+
let gettty1 = term_gettty(buf, 1)
2194+
2195+
call assert_equal(gettty, gettty0)
2196+
call assert_equal(job_info(g:job).tty_out, gettty0)
2197+
call assert_equal(job_info(g:job).tty_in, gettty1)
2198+
2199+
if has('unix')
2200+
" For unix, term_gettty(..., 0) and term_gettty(..., 1)
2201+
" are identical according to :help term_gettty()
2202+
call assert_equal(gettty0, gettty1)
2203+
call assert_match('^/dev/', gettty)
2204+
else
2205+
" ConPTY works on anonymous pipe.
2206+
if !has('conpty')
2207+
call assert_match('^\\\\.\\pipe\\', gettty0)
2208+
call assert_match('^\\\\.\\pipe\\', gettty1)
2209+
endif
2210+
endif
2211+
2212+
call assert_fails('call term_gettty(buf, 2)', 'E475:')
2213+
call assert_fails('call term_gettty(buf, -1)', 'E475:')
2214+
2215+
call assert_equal('', term_gettty(buf + 1))
2216+
2217+
call StopShellInTerminal(buf)
2218+
call term_wait(buf)
2219+
exe buf . 'bwipe'
2220+
endfunc
2221+
21892222
" When drawing the statusline the cursor position may not have been updated
21902223
" yet.
21912224
" 1. create a terminal, make it show 2 lines

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
505,
741743
/**/
742744
504,
743745
/**/

0 commit comments

Comments
 (0)