Skip to content

Commit b81bc77

Browse files
committed
patch 8.0.0911: terminal test takes too long
Problem: Terminal test takes too long. Solution: Instead of "sleep 1" use a Python program to briefly sleep.
1 parent da43b61 commit b81bc77

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

src/testdir/test_short_sleep.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/python
2+
#
3+
# Program that sleeps for 100 msec
4+
#
5+
# This requires Python 2.6 or later.
6+
7+
import time
8+
9+
if __name__ == "__main__":
10+
11+
time.sleep(0.1) # sleep 100 msec

src/testdir/test_terminal.vim

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ endif
66

77
source shared.vim
88

9+
let s:python = PythonProg()
10+
911
" Open a terminal with a shell, assign the job to g:job and return the buffer
1012
" number.
1113
func Run_shell_in_terminal(options)
@@ -319,41 +321,46 @@ func Test_terminal_curwin()
319321
endfunc
320322

321323
func Test_finish_close()
322-
" TODO: use something that takes much less than a whole second
323-
echo 'This will take five seconds...'
324324
call assert_equal(1, winnr('$'))
325325

326-
if has('win32')
327-
let cmd = $windir . '\system32\timeout.exe 1'
326+
if s:python != ''
327+
let cmd = s:python . " test_short_sleep.py"
328+
let waittime = 500
328329
else
329-
let cmd = 'sleep 1'
330+
echo 'This will take five seconds...'
331+
let waittime = 2000
332+
if has('win32')
333+
let cmd = $windir . '\system32\timeout.exe 1'
334+
else
335+
let cmd = 'sleep 1'
336+
endif
330337
endif
338+
331339
exe 'terminal ++close ' . cmd
332340
let buf = bufnr('')
333341
call assert_equal(2, winnr('$'))
334-
335342
wincmd p
336-
sleep 1200 msec
343+
call WaitFor("winnr('$') == 1", waittime)
337344
call assert_equal(1, winnr('$'))
338345

339346
call term_start(cmd, {'term_finish': 'close'})
340347
call assert_equal(2, winnr('$'))
341348
let buf = bufnr('')
342349
wincmd p
343-
sleep 1200 msec
350+
call WaitFor("winnr('$') == 1", waittime)
344351
call assert_equal(1, winnr('$'))
345352

346353
exe 'terminal ++open ' . cmd
347354
let buf = bufnr('')
348355
close
349-
sleep 1200 msec
356+
call WaitFor("winnr('$') == 2", waittime)
350357
call assert_equal(2, winnr('$'))
351358
bwipe
352359

353360
call term_start(cmd, {'term_finish': 'open'})
354361
let buf = bufnr('')
355362
close
356-
sleep 1200 msec
363+
call WaitFor("winnr('$') == 2", waittime)
357364
call assert_equal(2, winnr('$'))
358365

359366
bwipe

src/version.c

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

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
911,
772774
/**/
773775
910,
774776
/**/

0 commit comments

Comments
 (0)