mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Add negative test for type of job's env option
This commit is contained in:
parent
39963c6a04
commit
91b313a904
@ -12630,17 +12630,18 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
dictitem_T *item;
|
||||
item = tv_dict_find(job_opts, S_LEN("env"));
|
||||
if (item) {
|
||||
size_t custom_env_size = (size_t)tv_dict_len(item->di_tv.vval.v_dict);
|
||||
size_t i = 0;
|
||||
size_t env_size = 0;
|
||||
if (item->di_tv.v_type != VAR_DICT) {
|
||||
dictitem_T *job_env = tv_dict_find(job_opts, S_LEN("env"));
|
||||
if (job_env) {
|
||||
if (job_env->di_tv.v_type != VAR_DICT) {
|
||||
EMSG2(_(e_invarg2), "env");
|
||||
shell_free_argv(argv);
|
||||
return;
|
||||
}
|
||||
|
||||
size_t custom_env_size = (size_t)tv_dict_len(job_env->di_tv.vval.v_dict);
|
||||
size_t i = 0;
|
||||
size_t env_size = 0;
|
||||
|
||||
if (clear_env) {
|
||||
// + 1 for last null entry
|
||||
env = xmalloc((custom_env_size + 1) * sizeof(*env));
|
||||
@ -12655,7 +12656,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
assert(env); // env must be allocated at this point
|
||||
|
||||
TV_DICT_ITER(item->di_tv.vval.v_dict, var, {
|
||||
TV_DICT_ITER(job_env->di_tv.vval.v_dict, var, {
|
||||
const char *str = tv_get_string(&var->di_tv);
|
||||
assert(str);
|
||||
size_t len = STRLEN(var->di_key) + strlen(str) + strlen("=") + 1;
|
||||
|
@ -49,6 +49,18 @@ describe('jobs', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
it('must specify env option as a dict', function()
|
||||
command("let g:job_opts.env = v:true")
|
||||
local _, err = pcall(function()
|
||||
if iswin() then
|
||||
nvim('command', "let j = jobstart('set', g:job_opts)")
|
||||
else
|
||||
nvim('command', "let j = jobstart('env', g:job_opts)")
|
||||
end
|
||||
end)
|
||||
ok(string.find(err, "E475: Invalid argument: env") ~= nil)
|
||||
end)
|
||||
|
||||
it('append environment #env', function()
|
||||
nvim('command', "let $VAR = 'abc'")
|
||||
nvim('command', "let g:job_opts.env = {'TOTO': 'hello world'}")
|
||||
|
Loading…
Reference in New Issue
Block a user