Mercurial > vim
diff src/testdir/test_terminal.vim @ 12043:2796a2c9fc17 v8.0.0902
patch 8.0.0902: cannot specify directory or environment for a job
commit https://github.com/vim/vim/commit/05aafed54b50b602315ae55d83a7d089804cecb0
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 11 19:12:11 2017 +0200
patch 8.0.0902: cannot specify directory or environment for a job
Problem: Cannot specify directory or environment for a job.
Solution: Add the "cwd" and "env" arguments to job options. (Yasuhiro
Matsumoto, closes #1160)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 11 Aug 2017 19:15:04 +0200 |
parents | 9897241c08b5 |
children | 278aabefc7f9 |
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -8,8 +8,8 @@ source shared.vim " Open a terminal with a shell, assign the job to g:job and return the buffer " number. -func Run_shell_in_terminal() - let buf = term_start(&shell) +func Run_shell_in_terminal(options) + let buf = term_start(&shell, a:options) let termlist = term_list() call assert_equal(1, len(termlist)) @@ -32,7 +32,7 @@ func Stop_shell_in_terminal(buf) endfunc func Test_terminal_basic() - let buf = Run_shell_in_terminal() + let buf = Run_shell_in_terminal({}) if has("unix") call assert_match("^/dev/", job_info(g:job).tty) call assert_match("^/dev/", term_gettty('')) @@ -51,7 +51,7 @@ func Test_terminal_basic() endfunc func Test_terminal_make_change() - let buf = Run_shell_in_terminal() + let buf = Run_shell_in_terminal({}) call Stop_shell_in_terminal(buf) call term_wait(buf) @@ -65,7 +65,7 @@ func Test_terminal_make_change() endfunc func Test_terminal_wipe_buffer() - let buf = Run_shell_in_terminal() + let buf = Run_shell_in_terminal({}) call assert_fails(buf . 'bwipe', 'E517') exe buf . 'bwipe!' call WaitFor('job_status(g:job) == "dead"') @@ -76,7 +76,7 @@ func Test_terminal_wipe_buffer() endfunc func Test_terminal_hide_buffer() - let buf = Run_shell_in_terminal() + let buf = Run_shell_in_terminal({}) quit for nr in range(1, winnr('$')) call assert_notequal(winbufnr(nr), buf) @@ -266,9 +266,11 @@ func Test_terminal_size() endfunc func Test_finish_close() + return + " TODO: use something that takes much less than a whole second + echo 'This will take five seconds...' call assert_equal(1, winnr('$')) - " TODO: use something that takes much less than a whole second if has('win32') let cmd = $windir . '\system32\timeout.exe 1' else @@ -304,3 +306,32 @@ func Test_finish_close() bwipe endfunc + +func Test_terminal_cwd() + if !has('unix') + return + endif + call mkdir('Xdir') + let buf = term_start('pwd', {'cwd': 'Xdir'}) + sleep 100m + call term_wait(buf) + call assert_equal(getcwd() . '/Xdir', getline(1)) + + exe buf . 'bwipe' + call delete('Xdir', 'rf') +endfunc + +func Test_terminal_env() + if !has('unix') + return + endif + let buf = Run_shell_in_terminal({'env': {'TESTENV': 'correct'}}) + call term_wait(buf) + call term_sendkeys(buf, "echo $TESTENV\r") + call term_wait(buf) + call Stop_shell_in_terminal(buf) + call term_wait(buf) + call assert_equal('correct', getline(2)) + + exe buf . 'bwipe' +endfunc