comparison src/testdir/test_channel.vim @ 8426:02ce040591c8 v7.4.1504

commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 6 21:35:57 2016 +0100 patch 7.4.1504 Problem: No test for reading last-but-one line. Solution: Add a test.
author Christian Brabandt <cb@256bit.org>
date Sun, 06 Mar 2016 21:45:05 +0100
parents be45d4921f1f
children 800423dbc260
comparison
equal deleted inserted replaced
8425:dcb1b9c15ed1 8426:02ce040591c8
627 finally 627 finally
628 call job_stop(job) 628 call job_stop(job)
629 endtry 629 endtry
630 endfunc 630 endfunc
631 631
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
632 """""""""" 709 """"""""""
633 710
634 let s:unletResponse = '' 711 let s:unletResponse = ''
635 func s:UnletHandler(handle, msg) 712 func s:UnletHandler(handle, msg)
636 let s:unletResponse = a:msg 713 let s:unletResponse = a:msg