Skip to content

Commit

Permalink
test: verify the shell option works properly on execFile
Browse files Browse the repository at this point in the history
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 <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
jvelezpo authored and MylesBorins committed Mar 30, 2018
1 parent 32089bc commit b2a2a55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/parallel/test-child-process-execfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const uv = process.binding('uv');
const fixtures = require('../common/fixtures');

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

{
execFile(
Expand Down Expand Up @@ -38,3 +39,10 @@ const fixture = fixtures.path('exit.js');
child.kill();
child.emit('close', code, null);
}

{
// Verify the shell option works properly
execFile(process.execPath, [fixture, 0], execOpts, common.mustCall((err) => {
assert.ifError(err);
}));
}
6 changes: 6 additions & 0 deletions test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const TIMER = 200;
const SLEEP = 2000;

const start = Date.now();
const execOpts = { encoding: 'utf8', shell: true };
let err;
let caught = false;

Expand Down Expand Up @@ -103,3 +104,8 @@ assert.strictEqual(ret, `${msg}\n`);
return true;
});
}

// Verify the shell option works properly
assert.doesNotThrow(() => {
execFileSync(process.execPath, [], execOpts);
});

0 comments on commit b2a2a55

Please sign in to comment.