comparison src/testdir/test_terminal.vim @ 12345:76ab57a79183 v8.0.1052

patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options commit https://github.com/vim/vim/commit/e88fc7a574263fd399c6815378bcd8fd228d8b54 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 3 20:59:40 2017 +0200 patch 8.0.1052: term_start() does not allow in_io, out_io and err_io options Problem: term_start() does not allow in_io, out_io and err_io options. Solution: Add JO_OUT_IO to get_job_options().
author Christian Brabandt <cb@256bit.org>
date Sun, 03 Sep 2017 21:00:04 +0200
parents 72046661f6d0
children bb67396239a4
comparison
equal deleted inserted replaced
12344:a9079ccbb1a0 12345:76ab57a79183
162 162
163 " Nothing happens with invalid buffer number 163 " Nothing happens with invalid buffer number
164 call term_wait(1234) 164 call term_wait(1234)
165 165
166 call term_wait(buf) 166 call term_wait(buf)
167 if has('win32') 167 let g:buf = buf
168 " TODO: this should not be needed 168 call WaitFor('len(term_scrape(g:buf, 1)) > 0')
169 sleep 100m
170 endif
171 call Check_123(buf) 169 call Check_123(buf)
172 170
173 " Must still work after the job ended. 171 " Must still work after the job ended.
174 let g:job = term_getjob(buf) 172 let g:job = term_getjob(buf)
175 call WaitFor('job_status(g:job) == "dead"') 173 call WaitFor('job_status(g:job) == "dead"')
571 call term_wait('') 569 call term_wait('')
572 570
573 call delete('Xdir with spaces', 'rf') 571 call delete('Xdir with spaces', 'rf')
574 bwipe 572 bwipe
575 endfunc 573 endfunc
574
575 func Test_terminal_wrong_options()
576 call assert_fails('call term_start(&shell, {
577 \ "in_io": "file",
578 \ "in_name": "xxx",
579 \ "out_io": "file",
580 \ "out_name": "xxx",
581 \ "err_io": "file",
582 \ "err_name": "xxx"
583 \ })', 'E474:')
584 call assert_fails('call term_start(&shell, {
585 \ "out_buf": bufnr("%")
586 \ })', 'E474:')
587 call assert_fails('call term_start(&shell, {
588 \ "err_buf": bufnr("%")
589 \ })', 'E474:')
590 endfunc
591
592 func Test_terminal_redir_file()
593 let cmd = Get_cat_123_cmd()
594 let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'})
595 call term_wait(buf)
596 call WaitFor('len(readfile("Xfile")) > 0')
597 call assert_match('123', readfile('Xfile')[0])
598 call delete('Xfile')
599
600 if has('unix')
601 let buf = term_start('xyzabc', {'err_io': 'file', 'err_name': 'Xfile'})
602 call term_wait(buf)
603 call WaitFor('len(readfile("Xfile")) > 0')
604 call assert_match('executing job failed', readfile('Xfile')[0])
605 call delete('Xfile')
606
607 call writefile(['one line'], 'Xfile')
608 let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'})
609 call term_wait(buf)
610 call WaitFor('term_getline(' . buf . ', 1) == "one line"')
611 call assert_equal('one line', term_getline(buf, 1))
612 bwipe
613 call delete('Xfile')
614 endif
615 endfunc