Skip to content

Commit e295609

Browse files
committed
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)
1 parent 8657671 commit e295609

3 files changed

Lines changed: 44 additions & 38 deletions

File tree

src/testdir/test_channel.vim

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -879,19 +879,19 @@ endfunc
879879
func Test_pipe_err_to_buffer_name()
880880
call Run_test_pipe_err_to_buffer(1, 0, 1)
881881
endfunc
882-
882+
883883
func Test_pipe_err_to_buffer_nr()
884884
call Run_test_pipe_err_to_buffer(0, 0, 1)
885885
endfunc
886-
886+
887887
func Test_pipe_err_to_buffer_name_nomod()
888888
call Run_test_pipe_err_to_buffer(1, 1, 1)
889889
endfunc
890-
890+
891891
func Test_pipe_err_to_buffer_name_nomsg()
892892
call Run_test_pipe_err_to_buffer(1, 0, 0)
893893
endfunc
894-
894+
895895
func Test_pipe_both_to_buffer()
896896
if !has('job')
897897
return
@@ -966,15 +966,15 @@ func Run_pipe_through_sort(all, use_buffer)
966966
let options.in_top = 2
967967
let options.in_bot = 4
968968
endif
969-
let g:job = job_start('sort', options)
969+
let job = job_start('sort', options)
970970

971971
if !a:use_buffer
972-
call assert_equal("run", job_status(g:job))
973-
call ch_sendraw(g:job, "ccc\naaa\nddd\nbbb\neee\n")
974-
call ch_close_in(g:job)
972+
call assert_equal("run", job_status(job))
973+
call ch_sendraw(job, "ccc\naaa\nddd\nbbb\neee\n")
974+
call ch_close_in(job)
975975
endif
976976

977-
call WaitForAssert({-> assert_equal("dead", job_status(g:job))})
977+
call WaitForAssert({-> assert_equal("dead", job_status(job))})
978978

979979
sp sortout
980980
call WaitFor('line("$") > 3')
@@ -985,8 +985,7 @@ func Run_pipe_through_sort(all, use_buffer)
985985
call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4))
986986
endif
987987

988-
call job_stop(g:job)
989-
unlet g:job
988+
call job_stop(job)
990989
if a:use_buffer
991990
bwipe! sortin
992991
endif
@@ -1186,7 +1185,8 @@ func Test_pipe_to_buffer_raw()
11861185
split testout
11871186
let job = job_start([s:python, '-c',
11881187
\ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options)
1189-
call assert_equal("run", job_status(job))
1188+
" the job may be done quickly, also accept "dead"
1189+
call assert_match('^\%(dead\|run\)$', job_status(job))
11901190
call WaitFor('len(join(getline(1, "$"), "")) >= 10000')
11911191
try
11921192
let totlen = 0
@@ -1247,9 +1247,9 @@ func Test_out_cb()
12471247
endfunc
12481248
let job = job_start(s:python . " test_channel_pipe.py",
12491249
\ {'out_cb': dict.outHandler,
1250-
\ 'out_mode': 'json',
1251-
\ 'err_cb': dict.errHandler,
1252-
\ 'err_mode': 'json'})
1250+
\ 'out_mode': 'json',
1251+
\ 'err_cb': dict.errHandler,
1252+
\ 'err_mode': 'json'})
12531253
call assert_equal("run", job_status(job))
12541254
try
12551255
let g:Ch_outmsg = ''
@@ -1290,8 +1290,9 @@ func Test_out_close_cb()
12901290
endfunc
12911291
let job = job_start(s:python . " test_channel_pipe.py quit now",
12921292
\ {'out_cb': 'OutHandler',
1293-
\ 'close_cb': 'CloseHandler'})
1294-
call assert_equal("run", job_status(job))
1293+
\ 'close_cb': 'CloseHandler'})
1294+
" the job may be done quickly, also accept "dead"
1295+
call assert_match('^\%(dead\|run\)$', job_status(job))
12951296
try
12961297
call WaitForAssert({-> assert_equal('quit', g:Ch_msg1)})
12971298
call WaitForAssert({-> assert_equal(2, g:Ch_closemsg)})
@@ -1314,7 +1315,8 @@ func Test_read_in_close_cb()
13141315
endfunc
13151316
let job = job_start(s:python . " test_channel_pipe.py quit now",
13161317
\ {'close_cb': 'CloseHandler'})
1317-
call assert_equal("run", job_status(job))
1318+
" the job may be done quickly, also accept "dead"
1319+
call assert_match('^\%(dead\|run\)$', job_status(job))
13181320
try
13191321
call WaitForAssert({-> assert_equal('quit', g:Ch_received)})
13201322
finally
@@ -1338,7 +1340,8 @@ func Test_read_in_close_cb_incomplete()
13381340
endfunc
13391341
let job = job_start(s:python . " test_channel_pipe.py incomplete",
13401342
\ {'close_cb': 'CloseHandler'})
1341-
call assert_equal("run", job_status(job))
1343+
" the job may be done quickly, also accept "dead"
1344+
call assert_match('^\%(dead\|run\)$', job_status(job))
13421345
try
13431346
call WaitForAssert({-> assert_equal('incomplete', g:Ch_received)})
13441347
finally
@@ -1354,10 +1357,10 @@ func Test_out_cb_lambda()
13541357
call ch_log('Test_out_cb_lambda()')
13551358

13561359
let job = job_start(s:python . " test_channel_pipe.py",
1357-
\ {'out_cb': {ch, msg -> execute("let g:Ch_outmsg = 'lambda: ' . msg")},
1358-
\ 'out_mode': 'json',
1359-
\ 'err_cb': {ch, msg -> execute(":let g:Ch_errmsg = 'lambda: ' . msg")},
1360-
\ 'err_mode': 'json'})
1360+
\ {'out_cb': {ch, msg -> execute("let g:Ch_outmsg = 'lambda: ' . msg")},
1361+
\ 'out_mode': 'json',
1362+
\ 'err_cb': {ch, msg -> execute(":let g:Ch_errmsg = 'lambda: ' . msg")},
1363+
\ 'err_mode': 'json'})
13611364
call assert_equal("run", job_status(job))
13621365
try
13631366
let g:Ch_outmsg = ''
@@ -1385,14 +1388,13 @@ func Test_close_and_exit_cb()
13851388
let self.ret['exit_cb'] = job_status(a:job)
13861389
endfunc
13871390

1388-
let g:job = job_start(has('win32') ? 'cmd /c echo:' : 'echo', {
1389-
\ 'close_cb': g:retdict.close_cb,
1390-
\ 'exit_cb': g:retdict.exit_cb,
1391-
\ })
1392-
call assert_equal('run', job_status(g:job))
1393-
unlet g:job
1391+
let job = job_start([&shell, &shellcmdflag, 'echo'],
1392+
\ {'close_cb': g:retdict.close_cb,
1393+
\ 'exit_cb': g:retdict.exit_cb})
1394+
" the job may be done quickly, also accept "dead"
1395+
call assert_match('^\%(dead\|run\)$', job_status(job))
13941396
call WaitForAssert({-> assert_equal(2, len(g:retdict.ret))})
1395-
call assert_match('^\%(dead\|run\)', g:retdict.ret['close_cb'])
1397+
call assert_match('^\%(dead\|run\)$', g:retdict.ret['close_cb'])
13961398
call assert_equal('dead', g:retdict.ret['exit_cb'])
13971399
unlet g:retdict
13981400
endfunc
@@ -1415,7 +1417,7 @@ func Test_exit_cb_wipes_buf()
14151417
let g:wipe_buf = bufnr('')
14161418

14171419
let job = job_start(has('win32') ? 'cmd /c echo:' : ['true'],
1418-
\ {'exit_cb': 'ExitCbWipe'})
1420+
\ {'exit_cb': 'ExitCbWipe'})
14191421
let timer = timer_start(300, {-> feedkeys("\<Esc>", 'nt')}, {'repeat': 5})
14201422
call feedkeys(repeat('g', 1000) . 'o', 'ntx!')
14211423
call WaitForAssert({-> assert_equal("dead", job_status(job))})
@@ -1933,7 +1935,8 @@ func Test_keep_pty_open()
19331935
return
19341936
endif
19351937

1936-
let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"', {'out_io': 'null', 'err_io': 'null', 'pty': 1})
1938+
let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"',
1939+
\ {'out_io': 'null', 'err_io': 'null', 'pty': 1})
19371940
let elapsed = WaitFor({-> job_status(job) ==# 'dead'})
19381941
call assert_inrange(200, 1000, elapsed)
19391942
call job_stop(job)
@@ -1985,13 +1988,14 @@ func Test_raw_large_data()
19851988
try
19861989
let g:out = ''
19871990
let job = job_start(s:python . " test_channel_pipe.py",
1988-
\ {'mode': 'raw', 'drop': 'never', 'noblock': 1,
1989-
\ 'callback': {ch, msg -> execute('let g:out .= msg')}})
1991+
\ {'mode': 'raw', 'drop': 'never', 'noblock': 1,
1992+
\ 'callback': {ch, msg -> execute('let g:out .= msg')}})
19901993

1991-
let want = repeat('X', 79999) . "\n"
1994+
let outlen = 79999
1995+
let want = repeat('X', outlen) . "\n"
19921996
call ch_sendraw(job, want)
1993-
let g:Ch_job = job
1994-
call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))})
1997+
call WaitFor({-> len(g:out) >= outlen}, 10000)
1998+
call WaitForAssert({-> assert_equal("dead", job_status(job))})
19951999
call assert_equal(want, substitute(g:out, '\r', '', 'g'))
19962000
finally
19972001
call job_stop(job)

src/testdir/test_filechanged.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func Test_FileChangedShell_reload()
9090
endfunc
9191

9292
func Test_file_changed_dialog()
93-
if !has('unix')
93+
if !has('unix') || has('gui_running')
9494
return
9595
endif
9696
au! FileChangedShell

src/version.c

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

788788
static int included_patches[] =
789789
{ /* Add new patch number below this line */
790+
/**/
791+
820,
790792
/**/
791793
819,
792794
/**/

0 commit comments

Comments
 (0)