changeset 8676:289765409225 v7.4.1627

commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 20 22:16:56 2016 +0100 patch 7.4.1627 Problem: Channel out_cb and err_cb are not tested. Solution: Add a test.
author Christian Brabandt <cb@256bit.org>
date Sun, 20 Mar 2016 22:30:05 +0100
parents 114f60aadff6
children 2af728cb0b98
files src/testdir/test_channel.vim src/version.c
diffstat 2 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -994,6 +994,39 @@ func Test_reuse_channel()
   endtry
 endfunc
 
+func Test_out_cb()
+  if !has('job')
+    return
+  endif
+  call ch_log('Test_out_cb()')
+
+  let dict = {'thisis': 'dict: '}
+  func dict.outHandler(chan, msg) dict
+    let s:outmsg = self.thisis . a:msg
+  endfunc
+  func dict.errHandler(chan, msg) dict
+    let s:errmsg = self.thisis . a:msg
+  endfunc
+  let job = job_start(s:python . " test_channel_pipe.py",
+	\ {'out_cb': dict.outHandler,
+	\ 'out_mode': 'json',
+	\ 'err_cb': dict.errHandler,
+	\ 'err_mode': 'json'})
+  call assert_equal("run", job_status(job))
+  try
+    let s:outmsg = ''
+    let s:errmsg = ''
+    call ch_sendraw(job, "echo [0, \"hello\"]\n")
+    call ch_sendraw(job, "echoerr [0, \"there\"]\n")
+    call s:waitFor('s:outmsg != ""')
+    call assert_equal("dict: hello", s:outmsg)
+    call s:waitFor('s:errmsg != ""')
+    call assert_equal("dict: there", s:errmsg)
+  finally
+    call job_stop(job)
+  endtry
+endfunc
+
 """"""""""
 
 let s:unletResponse = ''
--- a/src/version.c
+++ b/src/version.c
@@ -749,6 +749,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1627,
+/**/
     1626,
 /**/
     1625,