Browse Source

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>
v4.x
cjihrig 8 years ago
committed by Myles Borins
parent
commit
527db40932
  1. 16
      test/sequential/test-child-process-execsync.js

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

@ -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;
});
}

Loading…
Cancel
Save