changeset 15625:858bf9c80c93 v8.1.0820

patch 8.1.0820: test for sending large data over channel sometimes fails commit https://github.com/vim/vim/commit/e295609be20c1b065d6b489214d70e171ae49234 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 25 21:01:17 2019 +0100 patch 8.1.0820: test for sending large data over channel sometimes fails Problem: Test for sending large data over channel sometimes fails. Solution: Handle that the job may have finished early. Also fix that file changed test doesn't work in the GUI and reduce flakyness. (Ozaki Kiichi, closes #3861)
author Bram Moolenaar <Bram@vim.org>
date Fri, 25 Jan 2019 21:15:12 +0100
parents 7832672e1efa
children a19dbbd9fae5
files src/testdir/test_channel.vim src/testdir/test_filechanged.vim src/version.c
diffstat 3 files changed, 44 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -879,19 +879,19 @@ endfunc
 func Test_pipe_err_to_buffer_name()
   call Run_test_pipe_err_to_buffer(1, 0, 1)
 endfunc
-  
+
 func Test_pipe_err_to_buffer_nr()
   call Run_test_pipe_err_to_buffer(0, 0, 1)
 endfunc
-  
+
 func Test_pipe_err_to_buffer_name_nomod()
   call Run_test_pipe_err_to_buffer(1, 1, 1)
 endfunc
-  
+
 func Test_pipe_err_to_buffer_name_nomsg()
   call Run_test_pipe_err_to_buffer(1, 0, 0)
 endfunc
-  
+
 func Test_pipe_both_to_buffer()
   if !has('job')
     return
@@ -966,15 +966,15 @@ func Run_pipe_through_sort(all, use_buff
     let options.in_top = 2
     let options.in_bot = 4
   endif
-  let g:job = job_start('sort', options)
+  let job = job_start('sort', options)
 
   if !a:use_buffer
-    call assert_equal("run", job_status(g:job))
-    call ch_sendraw(g:job, "ccc\naaa\nddd\nbbb\neee\n")
-    call ch_close_in(g:job)
+    call assert_equal("run", job_status(job))
+    call ch_sendraw(job, "ccc\naaa\nddd\nbbb\neee\n")
+    call ch_close_in(job)
   endif
 
-  call WaitForAssert({-> assert_equal("dead", job_status(g:job))})
+  call WaitForAssert({-> assert_equal("dead", job_status(job))})
 
   sp sortout
   call WaitFor('line("$") > 3')
@@ -985,8 +985,7 @@ func Run_pipe_through_sort(all, use_buff
     call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4))
   endif
 
-  call job_stop(g:job)
-  unlet g:job
+  call job_stop(job)
   if a:use_buffer
     bwipe! sortin
   endif
@@ -1186,7 +1185,8 @@ func Test_pipe_to_buffer_raw()
   split testout
   let job = job_start([s:python, '-c', 
         \ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options)
-  call assert_equal("run", job_status(job))
+  " the job may be done quickly, also accept "dead"
+  call assert_match('^\%(dead\|run\)$', job_status(job))
   call WaitFor('len(join(getline(1, "$"), "")) >= 10000')
   try
     let totlen = 0
@@ -1247,9 +1247,9 @@ func Test_out_cb()
   endfunc
   let job = job_start(s:python . " test_channel_pipe.py",
 	\ {'out_cb': dict.outHandler,
-	\ 'out_mode': 'json',
-	\ 'err_cb': dict.errHandler,
-	\ 'err_mode': 'json'})
+	\  'out_mode': 'json',
+	\  'err_cb': dict.errHandler,
+	\  'err_mode': 'json'})
   call assert_equal("run", job_status(job))
   try
     let g:Ch_outmsg = ''
@@ -1290,8 +1290,9 @@ func Test_out_close_cb()
   endfunc
   let job = job_start(s:python . " test_channel_pipe.py quit now",
 	\ {'out_cb': 'OutHandler',
-	\ 'close_cb': 'CloseHandler'})
-  call assert_equal("run", job_status(job))
+	\  'close_cb': 'CloseHandler'})
+  " the job may be done quickly, also accept "dead"
+  call assert_match('^\%(dead\|run\)$', job_status(job))
   try
     call WaitForAssert({-> assert_equal('quit', g:Ch_msg1)})
     call WaitForAssert({-> assert_equal(2, g:Ch_closemsg)})
@@ -1314,7 +1315,8 @@ func Test_read_in_close_cb()
   endfunc
   let job = job_start(s:python . " test_channel_pipe.py quit now",
 	\ {'close_cb': 'CloseHandler'})
-  call assert_equal("run", job_status(job))
+  " the job may be done quickly, also accept "dead"
+  call assert_match('^\%(dead\|run\)$', job_status(job))
   try
     call WaitForAssert({-> assert_equal('quit', g:Ch_received)})
   finally
@@ -1338,7 +1340,8 @@ func Test_read_in_close_cb_incomplete()
   endfunc
   let job = job_start(s:python . " test_channel_pipe.py incomplete",
 	\ {'close_cb': 'CloseHandler'})
-  call assert_equal("run", job_status(job))
+  " the job may be done quickly, also accept "dead"
+  call assert_match('^\%(dead\|run\)$', job_status(job))
   try
     call WaitForAssert({-> assert_equal('incomplete', g:Ch_received)})
   finally
@@ -1354,10 +1357,10 @@ func Test_out_cb_lambda()
   call ch_log('Test_out_cb_lambda()')
 
   let job = job_start(s:python . " test_channel_pipe.py",
-  \ {'out_cb': {ch, msg -> execute("let g:Ch_outmsg = 'lambda: ' . msg")},
-  \ 'out_mode': 'json',
-  \ 'err_cb': {ch, msg -> execute(":let g:Ch_errmsg = 'lambda: ' . msg")},
-  \ 'err_mode': 'json'})
+        \ {'out_cb': {ch, msg -> execute("let g:Ch_outmsg = 'lambda: ' . msg")},
+        \  'out_mode': 'json',
+        \  'err_cb': {ch, msg -> execute(":let g:Ch_errmsg = 'lambda: ' . msg")},
+        \  'err_mode': 'json'})
   call assert_equal("run", job_status(job))
   try
     let g:Ch_outmsg = ''
@@ -1385,14 +1388,13 @@ func Test_close_and_exit_cb()
     let self.ret['exit_cb'] = job_status(a:job)
   endfunc
 
-  let g:job = job_start(has('win32') ? 'cmd /c echo:' : 'echo', {
-        \ 'close_cb': g:retdict.close_cb,
-        \ 'exit_cb': g:retdict.exit_cb,
-        \ })
-  call assert_equal('run', job_status(g:job))
-  unlet g:job
+  let job = job_start([&shell, &shellcmdflag, 'echo'],
+        \ {'close_cb': g:retdict.close_cb,
+        \  'exit_cb': g:retdict.exit_cb})
+  " the job may be done quickly, also accept "dead"
+  call assert_match('^\%(dead\|run\)$', job_status(job))
   call WaitForAssert({-> assert_equal(2, len(g:retdict.ret))})
-  call assert_match('^\%(dead\|run\)', g:retdict.ret['close_cb'])
+  call assert_match('^\%(dead\|run\)$', g:retdict.ret['close_cb'])
   call assert_equal('dead', g:retdict.ret['exit_cb'])
   unlet g:retdict
 endfunc
@@ -1415,7 +1417,7 @@ func Test_exit_cb_wipes_buf()
   let g:wipe_buf = bufnr('')
 
   let job = job_start(has('win32') ? 'cmd /c echo:' : ['true'],
-			  \ {'exit_cb': 'ExitCbWipe'})
+	\ {'exit_cb': 'ExitCbWipe'})
   let timer = timer_start(300, {-> feedkeys("\<Esc>", 'nt')}, {'repeat': 5})
   call feedkeys(repeat('g', 1000) . 'o', 'ntx!')
   call WaitForAssert({-> assert_equal("dead", job_status(job))})
@@ -1933,7 +1935,8 @@ func Test_keep_pty_open()
     return
   endif
 
-  let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"', {'out_io': 'null', 'err_io': 'null', 'pty': 1})
+  let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"',
+        \ {'out_io': 'null', 'err_io': 'null', 'pty': 1})
   let elapsed = WaitFor({-> job_status(job) ==# 'dead'})
   call assert_inrange(200, 1000, elapsed)
   call job_stop(job)
@@ -1985,13 +1988,14 @@ func Test_raw_large_data()
   try
     let g:out = ''
     let job = job_start(s:python . " test_channel_pipe.py",
-	  \ {'mode': 'raw', 'drop': 'never', 'noblock': 1,
-      \  'callback': {ch, msg -> execute('let g:out .= msg')}})
+          \ {'mode': 'raw', 'drop': 'never', 'noblock': 1,
+          \  'callback': {ch, msg -> execute('let g:out .= msg')}})
 
-    let want = repeat('X', 79999) . "\n"
+    let outlen = 79999
+    let want = repeat('X', outlen) . "\n"
     call ch_sendraw(job, want)
-    let g:Ch_job = job
-    call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))})
+    call WaitFor({-> len(g:out) >= outlen}, 10000)
+    call WaitForAssert({-> assert_equal("dead", job_status(job))})
     call assert_equal(want, substitute(g:out, '\r', '', 'g'))
   finally
     call job_stop(job)
--- a/src/testdir/test_filechanged.vim
+++ b/src/testdir/test_filechanged.vim
@@ -90,7 +90,7 @@ func Test_FileChangedShell_reload()
 endfunc
 
 func Test_file_changed_dialog()
-  if !has('unix')
+  if !has('unix') || has('gui_running')
     return
   endif
   au! FileChangedShell
--- a/src/version.c
+++ b/src/version.c
@@ -788,6 +788,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    820,
+/**/
     819,
 /**/
     818,