@@ -629,6 +629,83 @@ func Test_pipe_to_buffer_json()
629629 endtry
630630endfunc
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 10 m
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
634711let s: unletResponse = ' '
0 commit comments