FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

removed 3rd arg from assert.throws() and changed assert.strict to ass… by bhavayAnand9 · Pull Request #22016 · nodejs/node · GitHub

/ node Public

removed 3rd arg from assert.throws() and changed assert.strict to ass… - #22016

Closed
bhavayAnand9 wants to merge 3 commits into
nodejs:masterfrom
bhavayAnand9:master
Closed

removed 3rd arg from assert.throws() and changed assert.strict to ass…#22016
bhavayAnand9 wants to merge 3 commits into
nodejs:masterfrom
bhavayAnand9:master

Conversation

Copy link
Copy Markdown
Contributor

…ert.ok

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

nodejs-github-bot added the test Issues and PRs related to the tests. label Jul 28, 2018
} finally {
assert.strictEqual(ret, undefined,
`should not have a return value, received ${ret}`);
assert.strictEqual(caught, true, 'execSync should throw');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Trott Jul 29, 2018
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

@@ -37,12 +37,10 @@ let caught = false;
assert.throws(
function() { execSync('exit -1', { shell: 'bad_shell' }); },
/spawnSync bad_shell ENOENT/,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you remove the trailing comma here and below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Removed trailing commas.

cjihrig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM once the comment regarding the strictEqual() change is addressed.

Trott commented Jul 29, 2018

Copy link
Copy Markdown
Member

Trott added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Jul 29, 2018

Copy link
Copy Markdown
Contributor

Trott commented Aug 1, 2018

Copy link
Copy Markdown
Member

Landed in ede279c

Trott closed this Aug 1, 2018
Trott pushed a commit to Trott/io.js that referenced this pull request Aug 1, 2018
Improve assertions in test-child-process-execsync by removing unneeded
third arguments and replacing equal checks with assert.ok() where
appropriate.

PR-URL: nodejs#22016
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

Trott commented Aug 1, 2018

Copy link
Copy Markdown
Member

Thanks for the contribution! 🎉

(If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.)

targos pushed a commit that referenced this pull request Aug 1, 2018
Improve assertions in test-child-process-execsync by removing unneeded
third arguments and replacing equal checks with assert.ok() where
appropriate.

PR-URL: #22016
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
targos mentioned this pull request Aug 1, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL