Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -164,10 +164,8 @@ func Test_terminal_scrape_123() call term_wait(1234) call term_wait(buf) - if has('win32') - " TODO: this should not be needed - sleep 100m - endif + let g:buf = buf + call WaitFor('len(term_scrape(g:buf, 1)) > 0') call Check_123(buf) " Must still work after the job ended. @@ -573,3 +571,45 @@ func Test_terminal_special_chars() call delete('Xdir with spaces', 'rf') bwipe endfunc + +func Test_terminal_wrong_options() + call assert_fails('call term_start(&shell, { + \ "in_io": "file", + \ "in_name": "xxx", + \ "out_io": "file", + \ "out_name": "xxx", + \ "err_io": "file", + \ "err_name": "xxx" + \ })', 'E474:') + call assert_fails('call term_start(&shell, { + \ "out_buf": bufnr("%") + \ })', 'E474:') + call assert_fails('call term_start(&shell, { + \ "err_buf": bufnr("%") + \ })', 'E474:') +endfunc + +func Test_terminal_redir_file() + let cmd = Get_cat_123_cmd() + let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'}) + call term_wait(buf) + call WaitFor('len(readfile("Xfile")) > 0') + call assert_match('123', readfile('Xfile')[0]) + call delete('Xfile') + + if has('unix') + let buf = term_start('xyzabc', {'err_io': 'file', 'err_name': 'Xfile'}) + call term_wait(buf) + call WaitFor('len(readfile("Xfile")) > 0') + call assert_match('executing job failed', readfile('Xfile')[0]) + call delete('Xfile') + + call writefile(['one line'], 'Xfile') + let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'}) + call term_wait(buf) + call WaitFor('term_getline(' . buf . ', 1) == "one line"') + call assert_equal('one line', term_getline(buf, 1)) + bwipe + call delete('Xfile') + endif +endfunc