diff src/testdir/test_channel.vim @ 10052:c1ba49441c90 v7.4.2297

commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 1 14:35:22 2016 +0200 patch 7.4.2297 Problem: When starting a job that reads from a buffer and reaching the end, the job hangs. Solution: Close the pipe or socket when all lines were read.
author Christian Brabandt <cb@256bit.org>
date Thu, 01 Sep 2016 14:45:06 +0200
parents 3b4b2ac811f0
children d4b7232fc63a
line wrap: on
line diff
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -792,6 +792,46 @@ func Test_pipe_from_buffer_nr()
   call Run_test_pipe_from_buffer(0)
 endfunc
 
+func Run_pipe_through_sort(all)
+  if !executable('sort') || !has('job')
+    return
+  endif
+  split sortin
+  call setline(1, ['ccc', 'aaa', 'ddd', 'bbb', 'eee'])
+  let options = {'in_io': 'buffer', 'in_name': 'sortin',
+	\ 'out_io': 'buffer', 'out_name': 'sortout'}
+  if !a:all
+    let options.in_top = 2
+    let options.in_bot = 4
+  endif
+  let g:job = job_start('sort', options)
+  call assert_equal("run", job_status(g:job))
+  call WaitFor('job_status(g:job) == "dead"')
+  call assert_equal("dead", job_status(g:job))
+  sp sortout
+  call assert_equal('Reading from channel output...', getline(1))
+  if a:all
+    call assert_equal(['aaa', 'bbb', 'ccc', 'ddd', 'eee'], getline(2, 6))
+  else
+    call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4))
+  endif
+
+  call job_stop(g:job)
+  unlet g:job
+  bwipe! sortin
+  bwipe! sortout
+endfunc
+
+func Test_pipe_through_sort_all()
+  call ch_log('Test_pipe_through_sort_all()')
+  call Run_pipe_through_sort(1)
+endfunc
+
+func Test_pipe_through_sort_some()
+  call ch_log('Test_pipe_through_sort_some()')
+  call Run_pipe_through_sort(0)
+endfunc
+
 func Test_pipe_to_nameless_buffer()
   if !has('job')
     return