To: vim_dev@googlegroups.com Subject: Patch 7.4.1504 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1504 (after 7.4.1502) Problem: No test for reading last-but-one line. Solution: Add a test. Files: src/testdir/test_channel.vim *** ../vim-7.4.1503/src/testdir/test_channel.vim 2016-03-06 21:33:58.286366293 +0100 --- src/testdir/test_channel.vim 2016-03-06 21:31:59.507633189 +0100 *************** *** 629,634 **** --- 629,711 ---- endtry endfunc + " Wait a little while for the last line, minus "offset", to equal "line". + func Wait_for_last_line(line, offset) + for i in range(100) + sleep 10m + if getline(line('$') - a:offset) == a:line + break + endif + endfor + 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 + split pipe-input + set buftype=nofile + + let job = job_start(s:python . " test_channel_pipe.py", + \ {'in-io': 'buffer', 'in-name': 'pipe-input', 'in-top': 0, + \ 'out-io': 'buffer', 'out-name': 'pipe-output'}) + call assert_equal("run", job_status(job)) + try + exe "normal Gaecho hello\" + exe bufwinnr('pipe-output') . "wincmd w" + call Wait_for_last_line('hello', 0) + call assert_equal('hello', getline('$')) + + exe bufwinnr('pipe-input') . "wincmd w" + exe "normal Gadouble this\" + exe bufwinnr('pipe-output') . "wincmd w" + call Wait_for_last_line('AND this', 0) + call assert_equal('this', getline(line('$') - 1)) + call assert_equal('AND this', getline('$')) + + bwipe! + exe bufwinnr('pipe-input') . "wincmd w" + bwipe! + finally + call job_stop(job) + endtry + 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 + + let job = job_start(s:python . " test_channel_pipe.py", + \ {'in-io': 'buffer', 'in-name': 'pipe-io', 'in-top': 0, + \ 'out-io': 'buffer', 'out-name': 'pipe-io'}) + call assert_equal("run", job_status(job)) + try + exe "normal Goecho hello\" + call Wait_for_last_line('hello', 1) + call assert_equal('hello', getline(line('$') - 1)) + + exe "normal Gadouble this\" + call Wait_for_last_line('AND this', 1) + call assert_equal('this', getline(line('$') - 2)) + call assert_equal('AND this', getline(line('$') - 1)) + + bwipe! + finally + call job_stop(job) + endtry + endfunc + """""""""" let s:unletResponse = '' *** ../vim-7.4.1503/src/version.c 2016-03-06 21:33:58.290366249 +0100 --- src/version.c 2016-03-06 21:35:20.181493016 +0100 *************** *** 745,746 **** --- 745,748 ---- { /* Add new patch number below this line */ + /**/ + 1504, /**/ -- No engineer can take a shower without wondering if some sort of Teflon coating would make showering unnecessary. (Scott Adams - The Dilbert principle) /// 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 ///