func s:get_sleep_cmd()
if s:python != ''
let cmd = s:python . " test_short_sleep.py"
- " 500 was not enough for Travis
- let waittime = 900
else
echo 'This will take five seconds...'
- let waittime = 2000
if has('win32')
let cmd = $windir . '\system32\timeout.exe 1'
else
let cmd = 'sleep 1'
endif
endif
- return [cmd, waittime]
+ return cmd
endfunc
func Test_terminal_finish_open_close()
call assert_equal(1, winnr('$'))
- let [cmd, waittime] = s:get_sleep_cmd()
+ let cmd = s:get_sleep_cmd()
" shell terminal closes automatically
terminal
" Wait for the shell to display a prompt
call WaitForAssert({-> assert_notequal('', term_getline(buf, 1))})
call StopShellInTerminal(buf)
- call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(1, winnr('$'))})
" shell terminal that does not close automatically
terminal ++noclose
exe 'terminal ++close ' . cmd
call assert_equal(2, winnr('$'))
wincmd p
- call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(1, winnr('$'))})
call term_start(cmd, {'term_finish': 'close'})
call assert_equal(2, winnr('$'))
wincmd p
- call WaitForAssert({-> assert_equal(1, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(1, winnr('$'))})
call assert_equal(1, winnr('$'))
exe 'terminal ++open ' . cmd
close!
- call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(2, winnr('$'))})
bwipe
call term_start(cmd, {'term_finish': 'open'})
close!
- call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(2, winnr('$'))})
bwipe
exe 'terminal ++hidden ++open ' . cmd
call assert_equal(1, winnr('$'))
- call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(2, winnr('$'))})
bwipe
call term_start(cmd, {'term_finish': 'open', 'hidden': 1})
call assert_equal(1, winnr('$'))
- call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(2, winnr('$'))})
bwipe
call assert_fails("call term_start(cmd, {'term_opencmd': 'open'})", 'E475:')
call term_start(cmd, {'term_finish': 'open', 'term_opencmd': '4split | buffer %d | let g:result = "opened the buffer in a window"'})
close!
- call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(2, winnr('$'))})
call assert_equal(4, winheight(0))
call assert_equal('opened the buffer in a window', g:result)
unlet g:result
endfunc
func Test_terminal_aucmd_on_close()
+ let s:called = 0
fun Nop()
let s:called = 1
endfun
au BufWinLeave * call Nop()
aug END
- let [cmd, waittime] = s:get_sleep_cmd()
+ let cmd = s:get_sleep_cmd()
call assert_equal(1, winnr('$'))
new
call setline(1, ['one', 'two'])
exe 'term ++close ' . cmd
wincmd p
- call WaitForAssert({-> assert_equal(2, winnr('$'))}, waittime)
+ call WaitForAssert({-> assert_equal(2, winnr('$'))})
call assert_equal(1, s:called)
bwipe!
call assert_equal('14+15', l)
call TermWait(buf)
- " It should appear as a single buffer line in vim
- let lastline = getline('$')
- call assert_equal('1+2+3+4+5+6+7+8+9+10+11+12+13+14+15', lastline)
+ " It should appear as a single buffer line in vim, once the job finished and
+ " the contents were moved to the buffer.
+ call WaitForAssert({-> assert_equal(
+ \ '1+2+3+4+5+6+7+8+9+10+11+12+13+14+15', getline('$'))})
bwipe!
endfunc