]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1627 v7.4.1627
authorBram Moolenaar <Bram@vim.org>
Sun, 20 Mar 2016 21:16:56 +0000 (22:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 20 Mar 2016 21:16:56 +0000 (22:16 +0100)
Problem:    Channel out_cb and err_cb are not tested.
Solution:   Add a test.

src/testdir/test_channel.vim
src/version.c

index 0fd7de9dd139e35ed5ce329378166c9236051f06..5b554b53131ef845d0f19fb5b35ec0977644fee5 100644 (file)
@@ -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 = ''
index fee3370d2ba2fc7e0ccbcae60bb3dbfce30ac260..149bbaf07f163ce0daa226e47fd0c514711f1db7 100644 (file)
@@ -748,6 +748,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1627,
 /**/
     1626,
 /**/