Skip to content

Commit b2a2a55

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 32089bc commit b2a2a55

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const TIMER = 200;
88
const SLEEP = 2000;
99

1010
const start = Date.now();
11+
const execOpts = { encoding: 'utf8', shell: true };
1112
let err;
1213
let caught = false;
1314

@@ -103,3 +104,8 @@ assert.strictEqual(ret, `${msg}\n`);
103104
return true;
104105
});
105106
}
107+
108+
// Verify the shell option works properly
109+
assert.doesNotThrow(() => {
110+
execFileSync(process.execPath, [], execOpts);
111+
});

0 commit comments

Comments
 (0)