Skip to content

Commit

Permalink
test: add coverage for execFileSync() errors
Browse files Browse the repository at this point in the history
This commit adds coverage for errors returned by execFileSync()
when the child process exits with a non-zero code.

PR-URL: #9211
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
cjihrig authored and evanlucas committed Nov 2, 2016
1 parent 9372aee commit 63ef099
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,19 @@ assert.strictEqual(ret, msg + '\n',
execSync('exit -1', {stdio: 'ignore'});
}, /Command failed: exit -1/);
}

// Verify the execFileSync() behavior when the child exits with a non-zero code.
{
const args = ['-e', 'process.exit(1)'];

assert.throws(() => {
execFileSync(process.execPath, args);
}, (err) => {
const msg = `Command failed: ${process.execPath} ${args.join(' ')}`;

assert(err instanceof Error);
assert.strictEqual(err.message.trim(), msg);
assert.strictEqual(err.status, 1);
return true;
});
}

0 comments on commit 63ef099

Please sign in to comment.