test: add coverage for execFileSync() errors
This commit adds coverage for errors returned by execFileSync() when the child process exits with a non-zero code. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
c5b07d4ec6
commit
a508000093
@ -87,3 +87,19 @@ assert.strictEqual(ret, msg + '\n',
|
|||||||
execSync('exit -1', {stdio: 'ignore'});
|
execSync('exit -1', {stdio: 'ignore'});
|
||||||
}, /Command failed: exit -1/);
|
}, /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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user