Skip to content
Permalink
Browse files

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: #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 committed Oct 20, 2016
1 parent c5b07d4 commit a5080000933108ff6d16bfb8705f18a8879fa138
Showing with 16 additions and 0 deletions.
  1. +16 −0 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;
});
}

0 comments on commit a508000

Please sign in to comment.
You can’t perform that action at this time.