Mercurial > vim
comparison src/testdir/test_channel.vim @ 9147:053bc64433ec v7.4.1857
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 29 16:17:08 2016 +0200
patch 7.4.1857
Problem: When a channel appends to a buffer that is 'nomodifiable' there is
an error but appending is done anyway.
Solution: Add the 'modifiable' option. Refuse to write to a 'nomodifiable'
when the value is 1.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 29 May 2016 16:30:06 +0200 |
parents | d319453f62b3 |
children | fb1a19011fbe |
comparison
equal
deleted
inserted
replaced
9146:23a544d11064 | 9147:053bc64433ec |
---|---|
674 call job_stop(job) | 674 call job_stop(job) |
675 call delete('Xoutput') | 675 call delete('Xoutput') |
676 endtry | 676 endtry |
677 endfunc | 677 endfunc |
678 | 678 |
679 func Run_test_pipe_to_buffer(use_name) | 679 func Run_test_pipe_to_buffer(use_name, nomod) |
680 if !has('job') | 680 if !has('job') |
681 return | 681 return |
682 endif | 682 endif |
683 call ch_log('Test_pipe_to_buffer()') | 683 call ch_log('Test_pipe_to_buffer()') |
684 let options = {'out_io': 'buffer'} | 684 let options = {'out_io': 'buffer'} |
688 else | 688 else |
689 sp pipe-output | 689 sp pipe-output |
690 let options['out_buf'] = bufnr('%') | 690 let options['out_buf'] = bufnr('%') |
691 quit | 691 quit |
692 let firstline = '' | 692 let firstline = '' |
693 endif | |
694 if a:nomod | |
695 let options['out_modifiable'] = 0 | |
693 endif | 696 endif |
694 let job = job_start(s:python . " test_channel_pipe.py", options) | 697 let job = job_start(s:python . " test_channel_pipe.py", options) |
695 call assert_equal("run", job_status(job)) | 698 call assert_equal("run", job_status(job)) |
696 try | 699 try |
697 let handle = job_getchannel(job) | 700 let handle = job_getchannel(job) |
703 call s:waitFor('line("$") >= 6') | 706 call s:waitFor('line("$") >= 6') |
704 if getline('$') == 'DETACH' | 707 if getline('$') == 'DETACH' |
705 $del | 708 $del |
706 endif | 709 endif |
707 call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this', 'Goodbye!'], getline(1, '$')) | 710 call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this', 'Goodbye!'], getline(1, '$')) |
711 if a:nomod | |
712 call assert_equal(0, &modifiable) | |
713 else | |
714 call assert_equal(1, &modifiable) | |
715 endif | |
708 bwipe! | 716 bwipe! |
709 finally | 717 finally |
710 call job_stop(job) | 718 call job_stop(job) |
711 endtry | 719 endtry |
712 endfunc | 720 endfunc |
713 | 721 |
714 func Test_pipe_to_buffer_name() | 722 func Test_pipe_to_buffer_name() |
715 call Run_test_pipe_to_buffer(1) | 723 call Run_test_pipe_to_buffer(1, 0) |
716 endfunc | 724 endfunc |
717 | 725 |
718 func Test_pipe_to_buffer_nr() | 726 func Test_pipe_to_buffer_nr() |
719 call Run_test_pipe_to_buffer(0) | 727 call Run_test_pipe_to_buffer(0, 0) |
720 endfunc | 728 endfunc |
721 | 729 |
722 func Run_test_pipe_err_to_buffer(use_name) | 730 func Test_pipe_to_buffer_name_nomod() |
731 call Run_test_pipe_to_buffer(1, 1) | |
732 endfunc | |
733 | |
734 func Run_test_pipe_err_to_buffer(use_name, nomod) | |
723 if !has('job') | 735 if !has('job') |
724 return | 736 return |
725 endif | 737 endif |
726 call ch_log('Test_pipe_err_to_buffer()') | 738 call ch_log('Test_pipe_err_to_buffer()') |
727 let options = {'err_io': 'buffer'} | 739 let options = {'err_io': 'buffer'} |
732 sp pipe-err | 744 sp pipe-err |
733 let options['err_buf'] = bufnr('%') | 745 let options['err_buf'] = bufnr('%') |
734 quit | 746 quit |
735 let firstline = '' | 747 let firstline = '' |
736 endif | 748 endif |
749 if a:nomod | |
750 let options['err_modifiable'] = 0 | |
751 endif | |
737 let job = job_start(s:python . " test_channel_pipe.py", options) | 752 let job = job_start(s:python . " test_channel_pipe.py", options) |
738 call assert_equal("run", job_status(job)) | 753 call assert_equal("run", job_status(job)) |
739 try | 754 try |
740 let handle = job_getchannel(job) | 755 let handle = job_getchannel(job) |
741 call ch_sendraw(handle, "echoerr line one\n") | 756 call ch_sendraw(handle, "echoerr line one\n") |
743 call ch_sendraw(handle, "doubleerr this\n") | 758 call ch_sendraw(handle, "doubleerr this\n") |
744 call ch_sendraw(handle, "quit\n") | 759 call ch_sendraw(handle, "quit\n") |
745 sp pipe-err | 760 sp pipe-err |
746 call s:waitFor('line("$") >= 5') | 761 call s:waitFor('line("$") >= 5') |
747 call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this'], getline(1, '$')) | 762 call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this'], getline(1, '$')) |
763 if a:nomod | |
764 call assert_equal(0, &modifiable) | |
765 else | |
766 call assert_equal(1, &modifiable) | |
767 endif | |
748 bwipe! | 768 bwipe! |
749 finally | 769 finally |
750 call job_stop(job) | 770 call job_stop(job) |
751 endtry | 771 endtry |
752 endfunc | 772 endfunc |
753 | 773 |
754 func Test_pipe_err_to_buffer_name() | 774 func Test_pipe_err_to_buffer_name() |
755 call Run_test_pipe_err_to_buffer(1) | 775 call Run_test_pipe_err_to_buffer(1, 0) |
756 endfunc | 776 endfunc |
757 | 777 |
758 func Test_pipe_err_to_buffer_nr() | 778 func Test_pipe_err_to_buffer_nr() |
759 call Run_test_pipe_err_to_buffer(0) | 779 call Run_test_pipe_err_to_buffer(0, 0) |
780 endfunc | |
781 | |
782 func Test_pipe_err_to_buffer_name_nomod() | |
783 call Run_test_pipe_err_to_buffer(1, 1) | |
760 endfunc | 784 endfunc |
761 | 785 |
762 func Test_pipe_both_to_buffer() | 786 func Test_pipe_both_to_buffer() |
763 if !has('job') | 787 if !has('job') |
764 return | 788 return |