Skip to content

Commit 52aeb2a

Browse files
jvelezpoMylesBorins
authored andcommitted
test: verify the shell option works properly on execFile
Useful for executing in a shell because it accepts arguments as an array instead of a string as exec does. Depending on the circumstances, that can prove to be useful if the arguments are already prepared. PR-URL: #18384 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent ffc8e8e commit 52aeb2a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/parallel/test-child-process-execfile.js

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const uv = process.binding('uv');
66
const fixtures = require('../common/fixtures');
77

88
const fixture = fixtures.path('exit.js');
9+
const execOpts = { encoding: 'utf8', shell: true };
910

1011
{
1112
execFile(
@@ -38,3 +39,10 @@ const fixture = fixtures.path('exit.js');
3839
child.kill();
3940
child.emit('close', code, null);
4041
}
42+
43+
{
44+
// Verify the shell option works properly
45+
execFile(process.execPath, [fixture, 0], execOpts, common.mustCall((err) => {
46+
assert.ifError(err);
47+
}));
48+
}

test/sequential/test-child-process-execsync.js

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const TIMER = 200;
2929
const SLEEP = 2000;
3030

3131
const start = Date.now();
32+
const execOpts = { encoding: 'utf8', shell: true };
3233
let err;
3334
let caught = false;
3435

@@ -141,3 +142,8 @@ assert.strictEqual(ret, `${msg}\n`);
141142
return true;
142143
});
143144
}
145+
146+
// Verify the shell option works properly
147+
assert.doesNotThrow(() => {
148+
execFileSync(process.execPath, [], execOpts);
149+
});

0 commit comments

Comments
 (0)