Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions 8 test/sequential/test-child-process-execsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ let caught = false;
// Verify that stderr is not accessed when a bad shell is used
assert.throws(
function() { execSync('exit -1', { shell: 'bad_shell' }); },
/spawnSync bad_shell ENOENT/,
'execSync did not throw the expected exception!'
/spawnSync bad_shell ENOENT/
);
assert.throws(
function() { execFileSync('exit -1', { shell: 'bad_shell' }); },
/spawnSync bad_shell ENOENT/,
'execFileSync did not throw the expected exception!'
/spawnSync bad_shell ENOENT/
);

let cmd, ret;
Expand All @@ -56,7 +54,7 @@ try {
} finally {
assert.strictEqual(ret, undefined,
`should not have a return value, received ${ret}`);
assert.strictEqual(caught, true, 'execSync should throw');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be changed. 1. caught should be a boolean and ok does a loose equal check. 2. The second argument would now be the error message and the third argument would be ignored.

Copy link
Member

@Trott Trott Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this should definitely be changed, but not the way it is in this PR right now.

There are at least two options.

Since caught is initialized to false and only ever changed to true inside of code that is in this file, strictEqual() is unnecessary. So this should be fine:

assert.ok(caught, 'execSync should throw');

Alternatively, if you want to insist on strictEqual() for the type-checking aspect, that's fine but then the string literal third argument should be removed (and possibly moved to a comment above the call) because you care about whether the test failed because caught was false or caught was the string "true" instead of the boolean true, etc.

// execSync should throw
assert.strictEqual(caught, true);

I think either of these options are better than what's there now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed assert.ok(caught, true, 'execSync should throw');
to assert.ok(caught, 'execSync should throw');

assert.ok(caught, 'execSync should throw');
const end = Date.now() - start;
assert(end < SLEEP);
assert(err.status > 128 || err.signal);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.