Patch 8.1.1777
Problem: Useless checks for job feature in channel test.
Solution: Remove the checks. Remove ch_log() calls.
Files: src/testdir/test_channel.vim
*** ../vim-8.1.1776/src/testdir/test_channel.vim 2019-07-29 22:10:04.309414434 +0200
--- src/testdir/test_channel.vim 2019-07-29 23:01:56.663836588 +0200
***************
*** 1,5 ****
! " Test for channel functions.
source check.vim
CheckFeature channel
--- 1,6 ----
! " Test for channel and job functions.
+ " When +channel is supported then +job is too, so we don't check for that.
source check.vim
CheckFeature channel
***************
*** 14,19 ****
--- 15,21 ----
" Uncomment the next line to see what happens. Output is in
" src/testdir/channellog.
+ " Add ch_log() calls where you want to see what happens.
" call ch_logfile('channellog', 'w')
let s:chopt = {}
***************
*** 56,65 ****
call assert_report("Can't open channel")
return
endif
! if has('job')
! " check that getjob without a job is handled correctly
! call assert_equal('no process', string(ch_getjob(handle)))
! endif
let dict = ch_info(handle)
call assert_true(
dict.id != 0)
call assert_equal('open', dict.status)
--- 58,67 ----
call assert_report("Can't open channel")
return
endif
!
! " check that getjob without a job is handled correctly
! call assert_equal('no process', string(ch_getjob(handle)))
!
let dict = ch_info(handle)
call assert_true(
dict.id != 0)
call assert_equal('open', dict.status)
***************
*** 445,454 ****
"""""""""
func Test_raw_pipe()
- if !has('job')
- return
- endif
- call ch_log('Test_raw_pipe()')
" Add a dummy close callback to avoid that messages are dropped when calling
" ch_canread().
" Also test the non-blocking option.
--- 447,452 ----
***************
*** 514,523 ****
endfunc
func Test_raw_pipe_blob()
- if !has('job')
- return
- endif
- call ch_log('Test_raw_pipe_blob()')
" Add a dummy close callback to avoid that messages are dropped when calling
" ch_canread().
" Also test the non-blocking option.
--- 512,517 ----
***************
*** 559,568 ****
endfunc
func Test_nl_pipe()
- if !has('job')
- return
- endif
- call ch_log('Test_nl_pipe()')
let job = job_start([s:python, "test_channel_pipe.py"])
call assert_equal("run", job_status(job))
try
--- 553,558 ----
***************
*** 587,640 ****
endtry
endfunc
- func Test_nl_err_to_out_pipe()
- if !has('job')
- return
- endif
- call ch_logfile('Xlog')
- call ch_log('Test_nl_err_to_out_pipe()')
- let job = job_start(s:python . " test_channel_pipe.py", {'err_io': 'out'})
- call assert_equal("run", job_status(job))
- try
- let handle = job_getchannel(job)
- call ch_sendraw(handle, "echo something\n")
- call assert_equal("something", ch_readraw(handle))
-
- call ch_sendraw(handle, "echoerr wrong\n")
- call assert_equal("wrong", ch_readraw(handle))
- finally
- call job_stop(job)
- call ch_logfile('')
- let loglines = readfile('Xlog')
- call assert_true(len(loglines) > 10)
- let found_test = 0
- let found_send = 0
- let found_recv = 0
- let found_stop = 0
- for l in loglines
- if l =~ 'Test_nl_err_to_out_pipe'
- let found_test = 1
- endif
- if l =~ 'SEND on.*echo something'
- let found_send = 1
- endif
- if l =~ 'RECV on.*something'
- let found_recv = 1
- endif
- if l =~ 'Stopping job with'
- let found_stop = 1
- endif
- endfor
- call assert_equal(1, found_test)
- call assert_equal(1, found_send)
- call assert_equal(1, found_recv)
- call assert_equal(1, found_stop)
- " On MS-Windows need to sleep for a moment to be able to delete the file.
- sleep 10m
- call delete('Xlog')
- endtry
- endfunc
-
func Stop_g_job()
call job_stop(g:job)
if has('win32')
--- 577,582 ----
***************
*** 646,655 ****
endfunc
func Test_nl_read_file()
- if !has('job')
- return
- endif
- call ch_log('Test_nl_read_file()')
call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput')
let g:job = job_start(s:python . " test_channel_pipe.py",
\ {'in_io': 'file', 'in_name': 'Xinput'})
--- 588,593 ----
***************
*** 667,676 ****
endfunc
func Test_nl_write_out_file()
- if !has('job')
- return
- endif
- call ch_log('Test_nl_write_out_file()')
let g:job = job_start(s:python . " test_channel_pipe.py",
\ {'out_io': 'file', 'out_name': 'Xoutput'})
call assert_equal("run", job_status(g:job))
--- 605,610 ----
***************
*** 688,697 ****
endfunc
func Test_nl_write_err_file()
- if !has('job')
- return
- endif
- call ch_log('Test_nl_write_err_file()')
let g:job = job_start(s:python . " test_channel_pipe.py",
\ {'err_io': 'file', 'err_name': 'Xoutput'})
call assert_equal("run", job_status(g:job))
--- 622,627 ----
***************
*** 708,717 ****
endfunc
func Test_nl_write_both_file()
- if !has('job')
- return
- endif
- call ch_log('Test_nl_write_both_file()')
let g:job = job_start(s:python . " test_channel_pipe.py",
\ {'out_io': 'file', 'out_name': 'Xoutput', 'err_io': 'out'})
call assert_equal("run", job_status(g:job))
--- 638,643 ----
***************
*** 734,743 ****
endfunc
func Run_test_pipe_to_buffer(use_name, nomod, do_msg)
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_to_buffer()')
let g:Ch_bufClosed = 'no'
let options = {'out_io': 'buffer', 'close_cb': 'BufCloseCb'}
let expected = ['', 'line one', 'line two', 'this', 'AND this', 'Goodbye!']
--- 660,665 ----
***************
*** 798,806 ****
endfunc
func Test_close_output_buffer()
- if !has('job')
- return
- endif
enew!
let test_lines = ['one', 'two']
call setline(1, test_lines)
--- 720,725 ----
***************
*** 829,838 ****
endfunc
func Run_test_pipe_err_to_buffer(use_name, nomod, do_msg)
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_err_to_buffer()')
let options = {'err_io': 'buffer'}
let expected = ['', 'line one', 'line two', 'this', 'AND this']
if a:use_name
--- 748,753 ----
***************
*** 890,899 ****
endfunc
func Test_pipe_both_to_buffer()
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_both_to_buffer()')
let job = job_start(s:python . " test_channel_pipe.py",
\ {'out_io': 'buffer', 'out_name': 'pipe-err', 'err_io': 'out'})
call assert_equal("run", job_status(job))
--- 805,810 ----
***************
*** 913,923 ****
endfunc
func Run_test_pipe_from_buffer(use_name)
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_from_buffer()')
-
sp pipe-input
call setline(1, ['echo one', 'echo two', 'echo three'])
let options = {'in_io': 'buffer', 'block_write': 1}
--- 824,829 ----
***************
*** 949,956 ****
endfunc
func Run_pipe_through_sort(all, use_buffer)
! if !executable('sort') || !has('job')
! return
endif
let options = {'out_io': 'buffer', 'out_name': 'sortout'}
if a:use_buffer
--- 855,862 ----
endfunc
func Run_pipe_through_sort(all, use_buffer)
! if !executable('sort')
! throw 'Skipped: sort program not found'
endif
let options = {'out_io': 'buffer', 'out_name': 'sortout'}
if a:use_buffer
***************
*** 1005,1014 ****
endfunc
func Test_pipe_to_nameless_buffer()
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_to_nameless_buffer()')
let job = job_start(s:python . " test_channel_pipe.py",
\ {'out_io': 'buffer'})
call assert_equal("run", job_status(job))
--- 911,916 ----
***************
*** 1026,1035 ****
endfunc
func Test_pipe_to_buffer_json()
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_to_buffer_json()')
let job = job_start(s:python . " test_channel_pipe.py",
\ {'out_io': 'buffer', 'out_mode': 'json'})
call assert_equal("run", job_status(job))
--- 928,933 ----
***************
*** 1057,1067 ****
endfunc
func Test_pipe_io_two_buffers()
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_io_two_buffers()')
-
" Create two buffers, one to read from and one to write to.
split pipe-output
set buftype=nofile
--- 955,960 ----
***************
*** 1095,1105 ****
endfunc
func Test_pipe_io_one_buffer()
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_io_one_buffer()')
-
" Create one buffer to read from and to write to.
split pipe-io
set buftype=nofile
--- 988,993 ----
***************
*** 1126,1132 ****
endfunc
func Test_write_to_buffer_and_scroll()
- CheckFeature job
if !CanRunVimInTerminal()
throw 'Skipped: cannot make screendumps'
endif
--- 1014,1019 ----
***************
*** 1146,1152 ****
END
call writefile(lines, 'XtestBufferScroll')
let buf = RunVimInTerminal('-S XtestBufferScroll', #{rows: 10})
! sleep 500m
call VerifyScreenDump(buf, 'Test_job_buffer_scroll_1', {})
" clean up
--- 1033,1039 ----
END
call writefile(lines, 'XtestBufferScroll')
let buf = RunVimInTerminal('-S XtestBufferScroll', #{rows: 10})
! call term_wait(buf, 100)
call VerifyScreenDump(buf, 'Test_job_buffer_scroll_1', {})
" clean up
***************
*** 1155,1165 ****
endfunc
func Test_pipe_null()
- if !has('job')
- return
- endif
- call ch_log('Test_pipe_null()')
-
" We cannot check that no I/O works, we only check that the job starts
" properly.
let job = job_start(s:python . " test_channel_pipe.py something",
--- 1042,1047 ----
***************
*** 1203,1212 ****
endfunc
func Test_pipe_to_buffer_raw()
- if !has('job')
- return
- endif
- call ch_log('Test_raw_pipe_to_buffer()')
let options = {'out_mode': 'raw', 'out_io': 'buffer', 'out_name': 'testout'}
split testout
let job = job_start([s:python, '-c',
--- 1085,1090 ----
***************
*** 1228,1238 ****
endfunc
func Test_reuse_channel()
- if !has('job')
- return
- endif
- call ch_log('Test_reuse_channel()')
-
let job = job_start(s:python . " test_channel_pipe.py")
call assert_equal("run", job_status(job))
let handle = job_getchannel(job)
--- 1106,1111 ----
***************
*** 1255,1265 ****
endfunc
func Test_out_cb()
- if !has('job')
- return
- endif
- call ch_log('Test_out_cb()')
-
let dict = {'thisis': 'dict: '}
func dict.outHandler(chan, msg) dict
if type(a:msg) == v:t_string
--- 1128,1133 ----
***************
*** 1296,1306 ****
endfunc
func Test_out_close_cb()
- if !has('job')
- return
- endif
- call ch_log('Test_out_close_cb()')
-
let s:counter = 1
let g:Ch_msg1 = ''
let g:Ch_closemsg = 0
--- 1164,1169 ----
***************
*** 1330,1340 ****
endfunc
func Test_read_in_close_cb()
- if !has('job')
- return
- endif
- call ch_log('Test_read_in_close_cb()')
-
let g:Ch_received = ''
func! CloseHandler(chan)
let g:Ch_received = ch_read(a:chan)
--- 1193,1198 ----
***************
*** 1353,1363 ****
" Use channel in NL mode but received text does not end in NL.
func Test_read_in_close_cb_incomplete()
- if !has('job')
- return
- endif
- call ch_log('Test_read_in_close_cb_incomplete()')
-
let g:Ch_received = ''
func! CloseHandler(chan)
while ch_status(a:chan, {'part': 'out'}) == 'buffered'
--- 1211,1216 ----
***************
*** 1377,1387 ****
endfunc
func Test_out_cb_lambda()
- if !has('job')
- return
- endif
- 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',
--- 1230,1235 ----
***************
*** 1401,1411 ****
endfunc
func Test_close_and_exit_cb()
- if !has('job')
- return
- endif
- call ch_log('Test_close_and_exit_cb')
-
let g:retdict = {'ret': {}}
func g:retdict.close_cb(ch) dict
let self.ret['close_cb'] = job_status(ch_getjob(a:ch))
--- 1249,1254 ----
***************
*** 1561,1584 ****
endfunc
func Test_exit_callback()
! if has('job')
! call ch_log('Test_exit_callback()')
! call s:run_server('Ch_test_exit_callback')
!
! " wait up to a second for the job to exit
! for i in range(100)
! if g:Ch_job_exit_ret == 'done'
! break
! endif
! sleep 10m
! " calling job_status() triggers the callback
! call job_status(g:Ch_exit_job)
! endfor
! call assert_equal('done', g:Ch_job_exit_ret)
! call assert_equal('dead', job_info(g:Ch_exit_job).status)
! unlet g:Ch_exit_job
! endif
endfunc
function MyExitTimeCb(job, status)
--- 1404,1424 ----
endfunc
func Test_exit_callback()
! call s:run_server('Ch_test_exit_callback')
! " wait up to a second for the job to exit
! for i in range(100)
! if g:Ch_job_exit_ret == 'done'
! break
! endif
! sleep 10m
! " calling job_status() triggers the callback
! call job_status(g:Ch_exit_job)
! endfor
!
! call assert_equal('done', g:Ch_job_exit_ret)
! call assert_equal('dead', job_info(g:Ch_exit_job).status)
! unlet g:Ch_exit_job
endfunc
function MyExitTimeCb(job, status)
***************
*** 1589,1598 ****
endfunction
func Test_exit_callback_interval()
- if !has('job')
- return
- endif
-
let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0}
let job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'})
let g:exit_cb_val.process = job_info(job).process
--- 1429,1434 ----
***************
*** 1671,1680 ****
endfunc
func Test_job_stop_immediately()
- if !has('job')
- return
- endif
-
let g:job = job_start([s:python, '-c', 'import time;time.sleep(10)'])
try
call job_stop(g:job)
--- 1507,1512 ----
***************
*** 1704,1711 ****
endfunc
func Test_collapse_buffers()
! if !executable('cat') || !has('job')
! return
endif
sp test_channel.vim
let g:linecount = line('$')
--- 1536,1543 ----
endfunc
func Test_collapse_buffers()
! if !executable('cat')
! throw 'Skipped: cat program not found'
endif
sp test_channel.vim
let g:linecount = line('$')
***************
*** 1718,1725 ****
endfunc
func Test_write_to_deleted_buffer()
! if !executable('echo') || !has('job')
! return
endif
let job = job_start('echo hello', {'out_io': 'buffer', 'out_name': 'test_buffer', 'out_msg': 0})
let bufnr = bufnr('test_buffer')
--- 1550,1557 ----
endfunc
func Test_write_to_deleted_buffer()
! if !executable('echo')
! throw 'Skipped: echo program not found'
endif
let job = job_start('echo hello', {'out_io': 'buffer', 'out_name': 'test_buffer', 'out_msg': 0})
let bufnr = bufnr('test_buffer')
***************
*** 1753,1760 ****
endfunc
func Test_raw_passes_nul()
! if !executable('cat') || !has('job')
! return
endif
" Test lines from the job containing NUL are stored correctly in a buffer.
--- 1585,1592 ----
endfunc
func Test_raw_passes_nul()
! if !executable('cat')
! throw 'Skipped: cat program not found'
endif
" Test lines from the job containing NUL are stored correctly in a buffer.
***************
*** 1790,1799 ****
endfunc
func Test_read_nonl_line()
- if !has('job')
- return
- endif
-
let g:linecount = 0
let arg = 'import sys;sys.stdout.write("1\n2\n3")'
call job_start([s:python, '-c', arg], {'callback': {-> execute('let g:linecount += 1')}})
--- 1622,1627 ----
***************
*** 1802,1811 ****
endfunc
func Test_read_nonl_in_close_cb()
- if !has('job')
- return
- endif
-
func s:close_cb(ch)
while ch_status(a:ch) == 'buffered'
let g:out .= ch_read(a:ch)
--- 1630,1635 ----
***************
*** 1821,1830 ****
endfunc
func Test_read_from_terminated_job()
- if !has('job')
- return
- endif
-
let g:linecount = 0
let arg = 'import os,sys;os.close(1);sys.stderr.write("test\n")'
call job_start([s:python, '-c', arg], {'callback': {-> execute('let g:linecount += 1')}})
--- 1645,1650 ----
***************
*** 1833,1839 ****
endfunc
func Test_job_start_windows()
- CheckFeature job
CheckMSWindows
" Check that backslash in $COMSPEC is handled properly.
--- 1653,1658 ----
***************
*** 1848,1855 ****
endfunc
func Test_env()
- CheckFeature job
-
let g:envstr = ''
if has('win32')
let cmd = ['cmd', '/c', 'echo %FOO%']
--- 1667,1672 ----
***************
*** 1863,1870 ****
endfunc
func Test_cwd()
- CheckFeature job
-
let g:envstr = ''
if has('win32')
let expect = $TEMP
--- 1680,1685 ----
***************
*** 1925,1932 ****
endfunc
func Test_list_args()
- CheckFeature job
-
call s:test_list_args('import sys;sys.stdout.write("hello world")', "hello world", 0)
call s:test_list_args('import sys;sys.stdout.write("hello\nworld")', "hello\nworld", 0)
call s:test_list_args('import sys;sys.stdout.write(''hello\nworld'')', "hello\nworld", 0)
--- 1740,1745 ----
***************
*** 1953,1970 ****
call s:test_list_args('print("hello\tworld")', "hello\tworld", 1)
endfunc
- " Do this last, it stops any channel log.
- func Test_zz_ch_log()
- call ch_logfile('Xlog', 'w')
- call ch_log('hello there')
- call ch_log('%s%s')
- call ch_logfile('')
- let text = readfile('Xlog')
- call assert_match("hello there", text[1])
- call assert_match("%s%s", text[2])
- call delete('Xlog')
- endfunc
-
func Test_keep_pty_open()
if !has('unix')
return
--- 1766,1771 ----
***************
*** 1978,1984 ****
endfunc
func Test_job_start_in_timer()
- CheckFeature job
CheckFeature timers
func OutCb(chan, msg)
--- 1779,1784 ----
***************
*** 2038,2044 ****
endfunc
func Test_no_hang_windows()
- CheckFeature job
CheckMSWindows
try
--- 1838,1843 ----
***************
*** 2075,2081 ****
endfunc
func Test_job_tty_in_out()
- CheckFeature job
CheckUnix
call writefile(['test'], 'Xtestin')
--- 1874,1879 ----
***************
*** 2124,2126 ****
--- 1922,1982 ----
call delete('Xtestout')
call delete('Xtesterr')
endfunc
+
+ " Do this last, it stops any channel log.
+ func Test_zz_nl_err_to_out_pipe()
+ call ch_logfile('Xlog')
+ call ch_log('Test_zz_nl_err_to_out_pipe()')
+ let job = job_start(s:python . " test_channel_pipe.py", {'err_io': 'out'})
+ call assert_equal("run", job_status(job))
+ try
+ let handle = job_getchannel(job)
+ call ch_sendraw(handle, "echo something\n")
+ call assert_equal("something", ch_readraw(handle))
+
+ call ch_sendraw(handle, "echoerr wrong\n")
+ call assert_equal("wrong", ch_readraw(handle))
+ finally
+ call job_stop(job)
+ call ch_logfile('')
+ let loglines = readfile('Xlog')
+ call assert_true(len(loglines) > 10)
+ let found_test = 0
+ let found_send = 0
+ let found_recv = 0
+ let found_stop = 0
+ for l in loglines
+ if l =~ 'Test_zz_nl_err_to_out_pipe'
+ let found_test = 1
+ endif
+ if l =~ 'SEND on.*echo something'
+ let found_send = 1
+ endif
+ if l =~ 'RECV on.*something'
+ let found_recv = 1
+ endif
+ if l =~ 'Stopping job with'
+ let found_stop = 1
+ endif
+ endfor
+ call assert_equal(1, found_test)
+ call assert_equal(1, found_send)
+ call assert_equal(1, found_recv)
+ call assert_equal(1, found_stop)
+ " On MS-Windows need to sleep for a moment to be able to delete the file.
+ sleep 10m
+ call delete('Xlog')
+ endtry
+ endfunc
+
+ " Do this last, it stops any channel log.
+ func Test_zz_ch_log()
+ call ch_logfile('Xlog', 'w')
+ call ch_log('hello there')
+ call ch_log('%s%s')
+ call ch_logfile('')
+ let text = readfile('Xlog')
+ call assert_match("hello there", text[1])
+ call assert_match("%s%s", text[2])
+ call delete('Xlog')
+ endfunc
*** ../vim-8.1.1776/src/version.c 2019-07-29 22:10:04.313414418 +0200
--- src/version.c 2019-07-29 22:59:57.952290634 +0200
***************
*** 779,780 ****
--- 779,782 ----
{ /* Add new patch number below this line */
+ /**/
+ 1777,
/**/
--
Sometimes you can protect millions of dollars in your budget simply by buying
a bag of cookies, dropping it on the budget anylyst's desk, and saying
something deeply personal such as "How was your weekend, big guy?"
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- Br...@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 ///