Mercurial > vim
diff src/testdir/test_channel.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 | 5cd9ba96561d |
children | 0a61213afdd2 |
line wrap: on
line diff
--- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1664,6 +1664,45 @@ func Test_read_from_terminated_job() call assert_equal(1, g:linecount) endfunc +func Test_env() + if !has('job') + return + endif + + let s:envstr = '' + if has('win32') + call job_start(['cmd', '/c', 'echo %FOO%'], {'callback': {ch,msg->execute(":let s:envstr .= msg")}, 'env':{'FOO': 'bar'}}) + else + call job_start([&shell, &shellcmdflag, 'echo $FOO'], {'callback': {ch,msg->execute(":let s:envstr .= msg")}, 'env':{'FOO': 'bar'}}) + endif + call WaitFor('"" != s:envstr') + call assert_equal("bar", s:envstr) + unlet s:envstr +endfunc + +func Test_cwd() + if !has('job') + return + endif + + let s:envstr = '' + if has('win32') + let expect = $TEMP + call job_start(['cmd', '/c', 'echo %CD%'], {'callback': {ch,msg->execute(":let s:envstr .= msg")}, 'cwd': expect}) + else + let expect = $HOME + call job_start(['pwd'], {'callback': {ch,msg->execute(":let s:envstr .= msg")}, 'cwd': expect}) + endif + call WaitFor('"" != s:envstr') + let expect = substitute(expect, '[/\\]$', '', '') + let s:envstr = substitute(s:envstr, '[/\\]$', '', '') + if $CI != '' && stridx(s:envstr, '/private/') == 0 + let s:envstr = s:envstr[8:] + endif + call assert_equal(expect, s:envstr) + unlet s:envstr +endfunc + function Ch_test_close_lambda(port) let handle = ch_open('localhost:' . a:port, s:chopt) if ch_status(handle) == "fail"