To: vim_dev@googlegroups.com Subject: Patch 8.1.0820 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0820 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) Files: src/testdir/test_channel.vim, src/testdir/test_filechanged.vim *** ../vim-8.1.0819/src/testdir/test_channel.vim 2019-01-24 23:11:44.631650199 +0100 --- src/testdir/test_channel.vim 2019-01-25 20:58:53.293743070 +0100 *************** *** 879,897 **** 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 --- 879,897 ---- 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,980 **** let options.in_top = 2 let options.in_bot = 4 endif ! let g: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) endif ! call WaitForAssert({-> assert_equal("dead", job_status(g:job))}) sp sortout call WaitFor('line("$") > 3') --- 966,980 ---- let options.in_top = 2 let options.in_bot = 4 endif ! let job = job_start('sort', options) if !a:use_buffer ! 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(job))}) sp sortout call WaitFor('line("$") > 3') *************** *** 985,992 **** call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4)) endif ! call job_stop(g:job) ! unlet g:job if a:use_buffer bwipe! sortin endif --- 985,991 ---- call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4)) endif ! call job_stop(job) if a:use_buffer bwipe! sortin endif *************** *** 1186,1192 **** 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)) call WaitFor('len(join(getline(1, "$"), "")) >= 10000') try let totlen = 0 --- 1185,1192 ---- split testout let job = job_start([s:python, '-c', \ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options) ! " 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,1255 **** 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'}) call assert_equal("run", job_status(job)) try let g:Ch_outmsg = '' --- 1247,1255 ---- 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'}) call assert_equal("run", job_status(job)) try let g:Ch_outmsg = '' *************** *** 1290,1297 **** 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)) try call WaitForAssert({-> assert_equal('quit', g:Ch_msg1)}) call WaitForAssert({-> assert_equal(2, g:Ch_closemsg)}) --- 1290,1298 ---- endfunc let job = job_start(s:python . " test_channel_pipe.py quit now", \ {'out_cb': 'OutHandler', ! \ '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,1320 **** endfunc let job = job_start(s:python . " test_channel_pipe.py quit now", \ {'close_cb': 'CloseHandler'}) ! call assert_equal("run", job_status(job)) try call WaitForAssert({-> assert_equal('quit', g:Ch_received)}) finally --- 1315,1322 ---- endfunc let job = job_start(s:python . " test_channel_pipe.py quit now", \ {'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_received)}) finally *************** *** 1338,1344 **** endfunc let job = job_start(s:python . " test_channel_pipe.py incomplete", \ {'close_cb': 'CloseHandler'}) ! call assert_equal("run", job_status(job)) try call WaitForAssert({-> assert_equal('incomplete', g:Ch_received)}) finally --- 1340,1347 ---- endfunc let job = job_start(s:python . " test_channel_pipe.py incomplete", \ {'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('incomplete', g:Ch_received)}) finally *************** *** 1354,1363 **** 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'}) call assert_equal("run", job_status(job)) try let g:Ch_outmsg = '' --- 1357,1366 ---- 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'}) call assert_equal("run", job_status(job)) try let g:Ch_outmsg = '' *************** *** 1385,1398 **** 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 call WaitForAssert({-> assert_equal(2, len(g:retdict.ret))}) ! call assert_match('^\%(dead\|run\)', g:retdict.ret['close_cb']) call assert_equal('dead', g:retdict.ret['exit_cb']) unlet g:retdict endfunc --- 1388,1400 ---- let self.ret['exit_cb'] = job_status(a:job) endfunc ! 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_equal('dead', g:retdict.ret['exit_cb']) unlet g:retdict endfunc *************** *** 1415,1421 **** let g:wipe_buf = bufnr('') let job = job_start(has('win32') ? 'cmd /c echo:' : ['true'], ! \ {'exit_cb': 'ExitCbWipe'}) let timer = timer_start(300, {-> feedkeys("\", 'nt')}, {'repeat': 5}) call feedkeys(repeat('g', 1000) . 'o', 'ntx!') call WaitForAssert({-> assert_equal("dead", job_status(job))}) --- 1417,1423 ---- let g:wipe_buf = bufnr('') let job = job_start(has('win32') ? 'cmd /c echo:' : ['true'], ! \ {'exit_cb': 'ExitCbWipe'}) let timer = timer_start(300, {-> feedkeys("\", 'nt')}, {'repeat': 5}) call feedkeys(repeat('g', 1000) . 'o', 'ntx!') call WaitForAssert({-> assert_equal("dead", job_status(job))}) *************** *** 1933,1939 **** return endif ! 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) --- 1935,1942 ---- return endif ! 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,1997 **** 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')}}) ! let want = repeat('X', 79999) . "\n" call ch_sendraw(job, want) ! let g:Ch_job = job ! call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))}) call assert_equal(want, substitute(g:out, '\r', '', 'g')) finally call job_stop(job) --- 1988,2001 ---- 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')}}) ! let outlen = 79999 ! let want = repeat('X', outlen) . "\n" call ch_sendraw(job, want) ! 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) *** ../vim-8.1.0819/src/testdir/test_filechanged.vim 2019-01-24 21:57:11.574719854 +0100 --- src/testdir/test_filechanged.vim 2019-01-25 20:54:17.931364655 +0100 *************** *** 90,96 **** endfunc func Test_file_changed_dialog() ! if !has('unix') return endif au! FileChangedShell --- 90,96 ---- endfunc func Test_file_changed_dialog() ! if !has('unix') || has('gui_running') return endif au! FileChangedShell *** ../vim-8.1.0819/src/version.c 2019-01-25 20:48:29.385157333 +0100 --- src/version.c 2019-01-25 21:00:22.821191796 +0100 *************** *** 789,790 **** --- 789,792 ---- { /* Add new patch number below this line */ + /**/ + 820, /**/ -- FIRST GUARD: Ah! Now ... we're not allowed to ... SIR LAUNCELOT runs him through, grabs his spear and stabs the other guard who collapses in a heap. Hiccoughs quietly. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///