Mercurial > vim
comparison src/testdir/test_channel.vim @ 8430:800423dbc260 v7.4.1506
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 6 23:06:25 2016 +0100
patch 7.4.1506
Problem: Job cannot read from a file.
Solution: Implement reading from a file for Unix.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 06 Mar 2016 23:15:05 +0100 |
parents | 02ce040591c8 |
children | 0e6fd2f802b3 |
comparison
equal
deleted
inserted
replaced
8429:eac8a407df71 | 8430:800423dbc260 |
---|---|
522 finally | 522 finally |
523 call job_stop(job) | 523 call job_stop(job) |
524 endtry | 524 endtry |
525 endfunc | 525 endfunc |
526 | 526 |
527 func Test_nl_read_file() | |
528 if !has('job') | |
529 return | |
530 endif | |
531 " TODO: make this work for MS-Windows. | |
532 if !has('unix') | |
533 return | |
534 endif | |
535 call ch_log('Test_nl_read_file()') | |
536 call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput') | |
537 let job = job_start(s:python . " test_channel_pipe.py", | |
538 \ {'in-io': 'file', 'in-name': 'Xinput'}) | |
539 call assert_equal("run", job_status(job)) | |
540 try | |
541 let handle = job_getchannel(job) | |
542 call assert_equal("something", ch_readraw(handle)) | |
543 call assert_equal("wrong", ch_readraw(handle, {'part': 'err'})) | |
544 call assert_equal("this", ch_readraw(handle)) | |
545 call assert_equal("AND this", ch_readraw(handle)) | |
546 finally | |
547 call job_stop(job) | |
548 call delete('Xinput') | |
549 endtry | |
550 endfunc | |
551 | |
527 func Test_pipe_to_buffer() | 552 func Test_pipe_to_buffer() |
528 if !has('job') | 553 if !has('job') |
529 return | 554 return |
530 endif | 555 endif |
531 call ch_log('Test_pipe_to_buffer()') | 556 call ch_log('Test_pipe_to_buffer()') |
554 | 579 |
555 func Test_pipe_from_buffer() | 580 func Test_pipe_from_buffer() |
556 if !has('job') | 581 if !has('job') |
557 return | 582 return |
558 endif | 583 endif |
559 call ch_logfile('channellog', 'w') | |
560 call ch_log('Test_pipe_from_buffer()') | 584 call ch_log('Test_pipe_from_buffer()') |
561 | 585 |
562 sp pipe-input | 586 sp pipe-input |
563 call setline(1, ['echo one', 'echo two', 'echo three']) | 587 call setline(1, ['echo one', 'echo two', 'echo three']) |
564 | 588 |
572 call assert_equal('three', ch_read(handle)) | 596 call assert_equal('three', ch_read(handle)) |
573 bwipe! | 597 bwipe! |
574 finally | 598 finally |
575 call job_stop(job) | 599 call job_stop(job) |
576 endtry | 600 endtry |
577 call ch_logfile('') | |
578 endfunc | 601 endfunc |
579 | 602 |
580 func Test_pipe_to_nameless_buffer() | 603 func Test_pipe_to_nameless_buffer() |
581 if !has('job') | 604 if !has('job') |
582 return | 605 return |