0
0
mirror of https://github.com/vim/vim.git synced 2025-10-10 06:24:10 -04:00

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)
This commit is contained in:
Bram Moolenaar
2019-01-25 21:01:17 +01:00
parent 865767126e
commit e295609be2
3 changed files with 44 additions and 38 deletions

View File

@@ -966,15 +966,15 @@ func Run_pipe_through_sort(all, use_buffer)
let options.in_top = 2 let options.in_top = 2
let options.in_bot = 4 let options.in_bot = 4
endif endif
let g:job = job_start('sort', options) let job = job_start('sort', options)
if !a:use_buffer if !a:use_buffer
call assert_equal("run", job_status(g:job)) call assert_equal("run", job_status(job))
call ch_sendraw(g:job, "ccc\naaa\nddd\nbbb\neee\n") call ch_sendraw(job, "ccc\naaa\nddd\nbbb\neee\n")
call ch_close_in(g:job) call ch_close_in(job)
endif endif
call WaitForAssert({-> assert_equal("dead", job_status(g:job))}) call WaitForAssert({-> assert_equal("dead", job_status(job))})
sp sortout sp sortout
call WaitFor('line("$") > 3') call WaitFor('line("$") > 3')
@@ -985,8 +985,7 @@ func Run_pipe_through_sort(all, use_buffer)
call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4)) call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4))
endif endif
call job_stop(g:job) call job_stop(job)
unlet g:job
if a:use_buffer if a:use_buffer
bwipe! sortin bwipe! sortin
endif endif
@@ -1186,7 +1185,8 @@ func Test_pipe_to_buffer_raw()
split testout split testout
let job = job_start([s:python, '-c', let job = job_start([s:python, '-c',
\ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options) \ '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') call WaitFor('len(join(getline(1, "$"), "")) >= 10000')
try try
let totlen = 0 let totlen = 0
@@ -1291,7 +1291,8 @@ func Test_out_close_cb()
let job = job_start(s:python . " test_channel_pipe.py quit now", let job = job_start(s:python . " test_channel_pipe.py quit now",
\ {'out_cb': 'OutHandler', \ {'out_cb': 'OutHandler',
\ 'close_cb': 'CloseHandler'}) \ '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 try
call WaitForAssert({-> assert_equal('quit', g:Ch_msg1)}) call WaitForAssert({-> assert_equal('quit', g:Ch_msg1)})
call WaitForAssert({-> assert_equal(2, g:Ch_closemsg)}) call WaitForAssert({-> assert_equal(2, g:Ch_closemsg)})
@@ -1314,7 +1315,8 @@ func Test_read_in_close_cb()
endfunc endfunc
let job = job_start(s:python . " test_channel_pipe.py quit now", let job = job_start(s:python . " test_channel_pipe.py quit now",
\ {'close_cb': 'CloseHandler'}) \ {'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 try
call WaitForAssert({-> assert_equal('quit', g:Ch_received)}) call WaitForAssert({-> assert_equal('quit', g:Ch_received)})
finally finally
@@ -1338,7 +1340,8 @@ func Test_read_in_close_cb_incomplete()
endfunc endfunc
let job = job_start(s:python . " test_channel_pipe.py incomplete", let job = job_start(s:python . " test_channel_pipe.py incomplete",
\ {'close_cb': 'CloseHandler'}) \ {'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 try
call WaitForAssert({-> assert_equal('incomplete', g:Ch_received)}) call WaitForAssert({-> assert_equal('incomplete', g:Ch_received)})
finally finally
@@ -1385,14 +1388,13 @@ func Test_close_and_exit_cb()
let self.ret['exit_cb'] = job_status(a:job) let self.ret['exit_cb'] = job_status(a:job)
endfunc endfunc
let g:job = job_start(has('win32') ? 'cmd /c echo:' : 'echo', { let job = job_start([&shell, &shellcmdflag, 'echo'],
\ 'close_cb': g:retdict.close_cb, \ {'close_cb': g:retdict.close_cb,
\ 'exit_cb': g:retdict.exit_cb, \ 'exit_cb': g:retdict.exit_cb})
\ }) " the job may be done quickly, also accept "dead"
call assert_equal('run', job_status(g:job)) call assert_match('^\%(dead\|run\)$', job_status(job))
unlet g:job
call WaitForAssert({-> assert_equal(2, len(g:retdict.ret))}) 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']) call assert_equal('dead', g:retdict.ret['exit_cb'])
unlet g:retdict unlet g:retdict
endfunc endfunc
@@ -1933,7 +1935,8 @@ func Test_keep_pty_open()
return return
endif 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'}) let elapsed = WaitFor({-> job_status(job) ==# 'dead'})
call assert_inrange(200, 1000, elapsed) call assert_inrange(200, 1000, elapsed)
call job_stop(job) call job_stop(job)
@@ -1988,10 +1991,11 @@ func Test_raw_large_data()
\ {'mode': 'raw', 'drop': 'never', 'noblock': 1, \ {'mode': 'raw', 'drop': 'never', 'noblock': 1,
\ 'callback': {ch, msg -> execute('let g:out .= msg')}}) \ '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) call ch_sendraw(job, want)
let g:Ch_job = job call WaitFor({-> len(g:out) >= outlen}, 10000)
call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))}) call WaitForAssert({-> assert_equal("dead", job_status(job))})
call assert_equal(want, substitute(g:out, '\r', '', 'g')) call assert_equal(want, substitute(g:out, '\r', '', 'g'))
finally finally
call job_stop(job) call job_stop(job)

View File

@@ -90,7 +90,7 @@ func Test_FileChangedShell_reload()
endfunc endfunc
func Test_file_changed_dialog() func Test_file_changed_dialog()
if !has('unix') if !has('unix') || has('gui_running')
return return
endif endif
au! FileChangedShell au! FileChangedShell

View File

@@ -787,6 +787,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
820,
/**/ /**/
819, 819,
/**/ /**/