comparison src/testdir/test_channel.vim @ 15454:1d2b5c016f17 v8.1.0735

patch 8.1.0735: cannot handle binary data commit https://github.com/vim/vim/commit/6e5ea8d2a995b32bbc5972edc4f827b959f2702f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 12 22:47:31 2019 +0100 patch 8.1.0735: cannot handle binary data Problem: Cannot handle binary data. Solution: Add the Blob type. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/3638)
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Jan 2019 23:00:06 +0100
parents 440e5071f3f8
children 3137345451a4
comparison
equal deleted inserted replaced
15453:cdee6e827112 15454:1d2b5c016f17
512 if j == job 512 if j == job
513 let found += 1 513 let found += 1
514 endif 514 endif
515 endfor 515 endfor
516 call assert_equal(1, found) 516 call assert_equal(1, found)
517 endfunc
518
519 func Test_raw_pipe_blob()
520 if !has('job')
521 return
522 endif
523 call ch_log('Test_raw_pipe_blob()')
524 " Add a dummy close callback to avoid that messages are dropped when calling
525 " ch_canread().
526 " Also test the non-blocking option.
527 let job = job_start(s:python . " test_channel_pipe.py",
528 \ {'mode': 'raw', 'drop': 'never', 'noblock': 1})
529 call assert_equal(v:t_job, type(job))
530 call assert_equal("run", job_status(job))
531
532 call assert_equal("open", ch_status(job))
533 call assert_equal("open", ch_status(job), {"part": "out"})
534
535 try
536 " Create a blob with the echo command and write it.
537 let blob = 0z00
538 let cmd = "echo something\n"
539 for i in range(0, len(cmd) - 1)
540 let blob[i] = char2nr(cmd[i])
541 endfor
542 call assert_equal(len(cmd), len(blob))
543 call ch_sendraw(job, blob)
544
545 " Read a blob with the reply.
546 let msg = ch_readblob(job)
547 let expected = 'something'
548 for i in range(0, len(expected) - 1)
549 call assert_equal(char2nr(expected[i]), msg[i])
550 endfor
551
552 let reply = ch_evalraw(job, "quit\n", {'timeout': 100})
553 call assert_equal("Goodbye!\n", substitute(reply, "\r", "", 'g'))
554 finally
555 call job_stop(job)
556 endtry
557
558 let g:Ch_job = job
559 call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))})
560 let info = job_info(job)
561 call assert_equal("dead", info.status)
517 endfunc 562 endfunc
518 563
519 func Test_nl_pipe() 564 func Test_nl_pipe()
520 if !has('job') 565 if !has('job')
521 return 566 return