aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/functional/core/job_spec.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index d285008a33..af2299945e 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -26,6 +26,7 @@ describe('jobs', function()
before_each(function()
clear()
+
channel = nvim('get_api_info')[1]
nvim('set_var', 'channel', channel)
source([[
@@ -48,6 +49,45 @@ describe('jobs', function()
]])
end)
+ it('append environment #env', function()
+ nvim('command', "let $VAR = 'abc'")
+ nvim('command', "let g:job_opts.env = {'TOTO': 'hello world'}")
+ if iswin() then
+ nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]])
+ else
+ nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]])
+ end
+
+ expect_msg_seq({
+ {'notification', 'stdout', {0, {'hello world abc', ''}}},
+ })
+ end)
+
+ it('replace environment #env', function()
+ nvim('command', "let $VAR = 'abc'")
+ nvim('command', "let g:job_opts.env = {'TOTO': 'hello world'}")
+ nvim('command', "let g:job_opts.clear_env = 1")
+
+ -- libuv ensures that certain "required" environment variables are
+ -- preserved if the user doesn't provide them in a custom environment
+ -- https://github.com/libuv/libuv/blob/635e0ce6073c5fbc96040e336b364c061441b54b/src/win/process.c#L672
+ -- https://github.com/libuv/libuv/blob/635e0ce6073c5fbc96040e336b364c061441b54b/src/win/process.c#L48-L60
+ --
+ -- Rather than expecting a completely empty environment, ensure that $VAR
+ -- is *not* in the environment but $TOTO is.
+ if iswin() then
+ nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]])
+ expect_msg_seq({
+ {'notification', 'stdout', {0, {'hello world %VAR%', ''}}}
+ })
+ else
+ nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]])
+ expect_msg_seq({
+ {'notification', 'stdout', {0, {'hello world', ''}}}
+ })
+ end
+ end)
+
it('uses &shell and &shellcmdflag if passed a string', function()
nvim('command', "let $VAR = 'abc'")
if iswin() then