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)
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index 89a784b..9cc3a55 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -8,8 +8,8 @@
" 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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