@@ -885,19 +885,19 @@ endfunc
885885func Test_pipe_err_to_buffer_name ()
886886 call Run_test_pipe_err_to_buffer (1 , 0 , 1 )
887887endfunc
888-
888+
889889func Test_pipe_err_to_buffer_nr ()
890890 call Run_test_pipe_err_to_buffer (0 , 0 , 1 )
891891endfunc
892-
892+
893893func Test_pipe_err_to_buffer_name_nomod ()
894894 call Run_test_pipe_err_to_buffer (1 , 1 , 1 )
895895endfunc
896-
896+
897897func Test_pipe_err_to_buffer_name_nomsg ()
898898 call Run_test_pipe_err_to_buffer (1 , 0 , 0 )
899899endfunc
900-
900+
901901func Test_pipe_both_to_buffer ()
902902 if ! has (' job' )
903903 return
@@ -972,15 +972,15 @@ func Run_pipe_through_sort(all, use_buffer)
972972 let options .in_top = 2
973973 let options .in_bot = 4
974974 endif
975- let g: job = job_start (' sort' , options )
975+ let job = job_start (' sort' , options )
976976
977977 if ! a: use_buffer
978- call assert_equal (" run" , job_status (g: job ))
979- call ch_sendraw (g: job , " ccc\n aaa\n ddd\n bbb\n eee\n " )
980- call ch_close_in (g: job )
978+ call assert_equal (" run" , job_status (job))
979+ call ch_sendraw (job, " ccc\n aaa\n ddd\n bbb\n eee\n " )
980+ call ch_close_in (job)
981981 endif
982982
983- call WaitForAssert ({- > assert_equal (" dead" , job_status (g: job ))})
983+ call WaitForAssert ({- > assert_equal (" dead" , job_status (job))})
984984
985985 sp sortout
986986 call WaitFor (' line("$") > 3' )
@@ -991,8 +991,7 @@ func Run_pipe_through_sort(all, use_buffer)
991991 call assert_equal ([' aaa' , ' bbb' , ' ddd' ], getline (2 , 4 ))
992992 endif
993993
994- call job_stop (g: job )
995- unlet g: job
994+ call job_stop (job)
996995 if a: use_buffer
997996 bwipe! sortin
998997 endif
@@ -1192,7 +1191,8 @@ func Test_pipe_to_buffer_raw()
11921191 split testout
11931192 let job = job_start ([s: python , ' -c' ,
11941193 \ ' import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]' ], options )
1195- call assert_equal (" run" , job_status (job))
1194+ " the job may be done quickly, also accept "dead"
1195+ call assert_match (' ^\%(dead\|run\)$' , job_status (job))
11961196 call WaitFor (' len(join(getline(1, "$"), "")) >= 10000' )
11971197 try
11981198 let totlen = 0
@@ -1253,9 +1253,9 @@ func Test_out_cb()
12531253 endfunc
12541254 let job = job_start (s: python . " test_channel_pipe.py" ,
12551255 \ {' out_cb' : dict .outHandler,
1256- \ ' out_mode' : ' json' ,
1257- \ ' err_cb' : dict .errHandler,
1258- \ ' err_mode' : ' json' })
1256+ \ ' out_mode' : ' json' ,
1257+ \ ' err_cb' : dict .errHandler,
1258+ \ ' err_mode' : ' json' })
12591259 call assert_equal (" run" , job_status (job))
12601260 try
12611261 let g: Ch_outmsg = ' '
@@ -1296,8 +1296,9 @@ func Test_out_close_cb()
12961296 endfunc
12971297 let job = job_start (s: python . " test_channel_pipe.py quit now" ,
12981298 \ {' out_cb' : ' OutHandler' ,
1299- \ ' close_cb' : ' CloseHandler' })
1300- call assert_equal (" run" , job_status (job))
1299+ \ ' close_cb' : ' CloseHandler' })
1300+ " the job may be done quickly, also accept "dead"
1301+ call assert_match (' ^\%(dead\|run\)$' , job_status (job))
13011302 try
13021303 call WaitForAssert ({- > assert_equal (' quit' , g: Ch_msg1 )})
13031304 call WaitForAssert ({- > assert_equal (2 , g: Ch_closemsg )})
@@ -1320,7 +1321,8 @@ func Test_read_in_close_cb()
13201321 endfunc
13211322 let job = job_start (s: python . " test_channel_pipe.py quit now" ,
13221323 \ {' close_cb' : ' CloseHandler' })
1323- call assert_equal (" run" , job_status (job))
1324+ " the job may be done quickly, also accept "dead"
1325+ call assert_match (' ^\%(dead\|run\)$' , job_status (job))
13241326 try
13251327 call WaitForAssert ({- > assert_equal (' quit' , g: Ch_received )})
13261328 finally
@@ -1344,7 +1346,8 @@ func Test_read_in_close_cb_incomplete()
13441346 endfunc
13451347 let job = job_start (s: python . " test_channel_pipe.py incomplete" ,
13461348 \ {' close_cb' : ' CloseHandler' })
1347- call assert_equal (" run" , job_status (job))
1349+ " the job may be done quickly, also accept "dead"
1350+ call assert_match (' ^\%(dead\|run\)$' , job_status (job))
13481351 try
13491352 call WaitForAssert ({- > assert_equal (' incomplete' , g: Ch_received )})
13501353 finally
@@ -1360,10 +1363,10 @@ func Test_out_cb_lambda()
13601363 call ch_log (' Test_out_cb_lambda()' )
13611364
13621365 let job = job_start (s: python . " test_channel_pipe.py" ,
1363- \ {' out_cb' : {ch , msg - > execute (" let g:Ch_outmsg = 'lambda: ' . msg" )},
1364- \ ' out_mode' : ' json' ,
1365- \ ' err_cb' : {ch , msg - > execute (" :let g:Ch_errmsg = 'lambda: ' . msg" )},
1366- \ ' err_mode' : ' json' })
1366+ \ {' out_cb' : {ch , msg - > execute (" let g:Ch_outmsg = 'lambda: ' . msg" )},
1367+ \ ' out_mode' : ' json' ,
1368+ \ ' err_cb' : {ch , msg - > execute (" :let g:Ch_errmsg = 'lambda: ' . msg" )},
1369+ \ ' err_mode' : ' json' })
13671370 call assert_equal (" run" , job_status (job))
13681371 try
13691372 let g: Ch_outmsg = ' '
@@ -1391,14 +1394,13 @@ func Test_close_and_exit_cb()
13911394 let self .ret [' exit_cb' ] = job_status (a: job )
13921395 endfunc
13931396
1394- let g: job = job_start (has (' win32' ) ? ' cmd /c echo:' : ' echo' , {
1395- \ ' close_cb' : g: retdict .close_cb,
1396- \ ' exit_cb' : g: retdict .exit_cb,
1397- \ })
1398- call assert_equal (' run' , job_status (g: job ))
1399- unlet g: job
1397+ let job = job_start ([&shell , &shellcmdflag , ' echo' ],
1398+ \ {' close_cb' : g: retdict .close_cb,
1399+ \ ' exit_cb' : g: retdict .exit_cb})
1400+ " the job may be done quickly, also accept "dead"
1401+ call assert_match (' ^\%(dead\|run\)$' , job_status (job))
14001402 call WaitForAssert ({- > assert_equal (2 , len (g: retdict .ret ))})
1401- call assert_match (' ^\%(dead\|run\)' , g: retdict .ret [' close_cb' ])
1403+ call assert_match (' ^\%(dead\|run\)$ ' , g: retdict .ret [' close_cb' ])
14021404 call assert_equal (' dead' , g: retdict .ret [' exit_cb' ])
14031405 unlet g: retdict
14041406endfunc
@@ -1421,7 +1423,7 @@ func Test_exit_cb_wipes_buf()
14211423 let g: wipe_buf = bufnr (' ' )
14221424
14231425 let job = job_start (has (' win32' ) ? ' cmd /c echo:' : [' true' ],
1424- \ {' exit_cb' : ' ExitCbWipe' })
1426+ \ {' exit_cb' : ' ExitCbWipe' })
14251427 let timer = timer_start (300 , {- > feedkeys (" \<Esc> " , ' nt' )}, {' repeat' : 5 })
14261428 call feedkeys (repeat (' g' , 1000 ) . ' o' , ' ntx!' )
14271429 call WaitForAssert ({- > assert_equal (" dead" , job_status (job))})
@@ -1939,7 +1941,8 @@ func Test_keep_pty_open()
19391941 return
19401942 endif
19411943
1942- let job = job_start (s: python . ' -c "import time;time.sleep(0.2)"' , {' out_io' : ' null' , ' err_io' : ' null' , ' pty' : 1 })
1944+ let job = job_start (s: python . ' -c "import time;time.sleep(0.2)"' ,
1945+ \ {' out_io' : ' null' , ' err_io' : ' null' , ' pty' : 1 })
19431946 let elapsed = WaitFor ({- > job_status (job) == # ' dead' })
19441947 call assert_inrange (200 , 1000 , elapsed)
19451948 call job_stop (job)
@@ -1991,13 +1994,14 @@ func Test_raw_large_data()
19911994 try
19921995 let g: out = ' '
19931996 let job = job_start (s: python . " test_channel_pipe.py" ,
1994- \ {' mode' : ' raw' , ' drop' : ' never' , ' noblock' : 1 ,
1995- \ ' callback' : {ch , msg - > execute (' let g:out .= msg' )}})
1997+ \ {' mode' : ' raw' , ' drop' : ' never' , ' noblock' : 1 ,
1998+ \ ' callback' : {ch , msg - > execute (' let g:out .= msg' )}})
19961999
1997- let want = repeat (' X' , 79999 ) . " \n "
2000+ let outlen = 79999
2001+ let want = repeat (' X' , outlen) . " \n "
19982002 call ch_sendraw (job, want)
1999- let g: Ch_job = job
2000- call WaitForAssert ({- > assert_equal (" dead" , job_status (g: Ch_job ))})
2003+ call WaitFor ({ - > len ( g: out ) >= outlen}, 10000 )
2004+ call WaitForAssert ({- > assert_equal (" dead" , job_status (job ))})
20012005 call assert_equal (want, substitute (g: out , ' \r' , ' ' , ' g' ))
20022006 finally
20032007 call job_stop (job)
0 commit comments