]> granicus.if.org Git - vim/commitdiff
patch 8.0.0911: terminal test takes too long v8.0.0911
authorBram Moolenaar <Bram@vim.org>
Fri, 11 Aug 2017 20:45:01 +0000 (22:45 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 11 Aug 2017 20:45:01 +0000 (22:45 +0200)
Problem:    Terminal test takes too long.
Solution:   Instead of "sleep 1" use a Python program to briefly sleep.

src/testdir/test_short_sleep.py [new file with mode: 0644]
src/testdir/test_terminal.vim
src/version.c

diff --git a/src/testdir/test_short_sleep.py b/src/testdir/test_short_sleep.py
new file mode 100644 (file)
index 0000000..a290443
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+#
+# Program that sleeps for 100 msec
+#
+# This requires Python 2.6 or later.
+
+import time
+
+if __name__ == "__main__":
+
+    time.sleep(0.1)  # sleep 100 msec
index 38fbbd9dbaba760c815cf3b4feeb61cca206efb9..9012bec142e8b6e5a5bac1ea3ecae549de52d84e 100644 (file)
@@ -6,6 +6,8 @@ endif
 
 source shared.vim
 
+let s:python = PythonProg()
+
 " Open a terminal with a shell, assign the job to g:job and return the buffer
 " number.
 func Run_shell_in_terminal(options)
@@ -319,41 +321,46 @@ func Test_terminal_curwin()
 endfunc
 
 func Test_finish_close()
-  " TODO: use something that takes much less than a whole second
-  echo 'This will take five seconds...'
   call assert_equal(1, winnr('$'))
 
-  if has('win32')
-    let cmd = $windir . '\system32\timeout.exe 1'
+  if s:python != ''
+    let cmd = s:python . " test_short_sleep.py"
+    let waittime = 500
   else
-    let cmd = 'sleep 1'
+    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
+
   exe 'terminal ++close ' . cmd
   let buf = bufnr('')
   call assert_equal(2, winnr('$'))
-
   wincmd p
-  sleep 1200 msec
+  call WaitFor("winnr('$') == 1", waittime)
   call assert_equal(1, winnr('$'))
 
   call term_start(cmd, {'term_finish': 'close'})
   call assert_equal(2, winnr('$'))
   let buf = bufnr('')
   wincmd p
-  sleep 1200 msec
+  call WaitFor("winnr('$') == 1", waittime)
   call assert_equal(1, winnr('$'))
 
   exe 'terminal ++open ' . cmd
   let buf = bufnr('')
   close
-  sleep 1200 msec
+  call WaitFor("winnr('$') == 2", waittime)
   call assert_equal(2, winnr('$'))
   bwipe
 
   call term_start(cmd, {'term_finish': 'open'})
   let buf = bufnr('')
   close
-  sleep 1200 msec
+  call WaitFor("winnr('$') == 2", waittime)
   call assert_equal(2, winnr('$'))
 
   bwipe
index d88001de4a6ef672b0b19a4cb47b2a6f29680e96..2972730c41032326353722ffe1f5f39886a3342a 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    911,
 /**/
     910,
 /**/