mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: new test for setting environment
This commit is contained in:
parent
4598e489c7
commit
f3fcaedfad
@ -26,6 +26,7 @@ describe('jobs', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
channel = nvim('get_api_info')[1]
|
channel = nvim('get_api_info')[1]
|
||||||
nvim('set_var', 'channel', channel)
|
nvim('set_var', 'channel', channel)
|
||||||
source([[
|
source([[
|
||||||
@ -48,6 +49,45 @@ describe('jobs', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
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()
|
it('uses &shell and &shellcmdflag if passed a string', function()
|
||||||
nvim('command', "let $VAR = 'abc'")
|
nvim('command', "let $VAR = 'abc'")
|
||||||
if iswin() then
|
if iswin() then
|
||||||
|
Loading…
Reference in New Issue
Block a user