Skip to content

Commit 3f39f64

Browse files
committed
patch 7.4.1504
Problem: No test for reading last-but-one line. Solution: Add a test.
1 parent 839fd11 commit 3f39f64

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

src/testdir/test_channel.vim

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,83 @@ func Test_pipe_to_buffer_json()
629629
endtry
630630
endfunc
631631

632+
" Wait a little while for the last line, minus "offset", to equal "line".
633+
func Wait_for_last_line(line, offset)
634+
for i in range(100)
635+
sleep 10m
636+
if getline(line('$') - a:offset) == a:line
637+
break
638+
endif
639+
endfor
640+
endfunc
641+
642+
func Test_pipe_io_two_buffers()
643+
if !has('job')
644+
return
645+
endif
646+
call ch_log('Test_pipe_io_two_buffers()')
647+
648+
" Create two buffers, one to read from and one to write to.
649+
split pipe-output
650+
set buftype=nofile
651+
split pipe-input
652+
set buftype=nofile
653+
654+
let job = job_start(s:python . " test_channel_pipe.py",
655+
\ {'in-io': 'buffer', 'in-name': 'pipe-input', 'in-top': 0,
656+
\ 'out-io': 'buffer', 'out-name': 'pipe-output'})
657+
call assert_equal("run", job_status(job))
658+
try
659+
exe "normal Gaecho hello\<CR>"
660+
exe bufwinnr('pipe-output') . "wincmd w"
661+
call Wait_for_last_line('hello', 0)
662+
call assert_equal('hello', getline('$'))
663+
664+
exe bufwinnr('pipe-input') . "wincmd w"
665+
exe "normal Gadouble this\<CR>"
666+
exe bufwinnr('pipe-output') . "wincmd w"
667+
call Wait_for_last_line('AND this', 0)
668+
call assert_equal('this', getline(line('$') - 1))
669+
call assert_equal('AND this', getline('$'))
670+
671+
bwipe!
672+
exe bufwinnr('pipe-input') . "wincmd w"
673+
bwipe!
674+
finally
675+
call job_stop(job)
676+
endtry
677+
endfunc
678+
679+
func Test_pipe_io_one_buffer()
680+
if !has('job')
681+
return
682+
endif
683+
call ch_log('Test_pipe_io_one_buffer()')
684+
685+
" Create one buffer to read from and to write to.
686+
split pipe-io
687+
set buftype=nofile
688+
689+
let job = job_start(s:python . " test_channel_pipe.py",
690+
\ {'in-io': 'buffer', 'in-name': 'pipe-io', 'in-top': 0,
691+
\ 'out-io': 'buffer', 'out-name': 'pipe-io'})
692+
call assert_equal("run", job_status(job))
693+
try
694+
exe "normal Goecho hello\<CR>"
695+
call Wait_for_last_line('hello', 1)
696+
call assert_equal('hello', getline(line('$') - 1))
697+
698+
exe "normal Gadouble this\<CR>"
699+
call Wait_for_last_line('AND this', 1)
700+
call assert_equal('this', getline(line('$') - 2))
701+
call assert_equal('AND this', getline(line('$') - 1))
702+
703+
bwipe!
704+
finally
705+
call job_stop(job)
706+
endtry
707+
endfunc
708+
632709
""""""""""
633710

634711
let s:unletResponse = ''

src/version.c

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

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1504,
746748
/**/
747749
1503,
748750
/**/

0 commit comments

Comments
 (0)