diff src/testdir/test_channel.vim @ 8324:5e88bd55b789 v7.4.1454

commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 28 19:50:51 2016 +0100 patch 7.4.1454 Problem: The exit callback test is flaky. Solution: Loop to wait for a short time up to a second.
author Christian Brabandt <cb@256bit.org>
date Sun, 28 Feb 2016 20:00:04 +0100
parents ac0c43e7af20
children 8fa75a4c39bd
line wrap: on
line diff
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -535,14 +535,21 @@ endfunc
 
 func Test_exit_callback()
   if has('job')
+    call ch_log('Test_exit_callback()')
     call s:run_server('s:test_exit_callback')
 
-    " the job may take a little while to exit
-    sleep 50m
+    " wait up to a second for the job to exit
+    for i in range(100)
+      if s:job_exit_ret == 'done'
+	break
+      endif
+      sleep 10m
+      " calling job_status() triggers the callback
+      call job_status(s:exit_job)
+    endfor
 
-    " calling job_status() triggers the callback
-    call job_status(s:exit_job)
     call assert_equal('done', s:job_exit_ret)
+    unlet s:exit_job
   endif
 endfunc
 
@@ -571,3 +578,5 @@ func Test_close_callback()
   call s:run_server('s:test_close_callback')
 endfunc
 
+" Uncomment this to see what happens, output is in src/testdir/channellog.
+" call ch_logfile('channellog', 'w')