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

test: replaces assert.throws() with common.expectsError() by saudkhanzada · Pull Request #22689 · nodejs/node · GitHub

/ node Public

test: replaces assert.throws() with common.expectsError() - #22689

Closed
saudkhanzada wants to merge 1 commit into
nodejs:masterfrom
saudkhanzada:master
Closed

test: replaces assert.throws() with common.expectsError()#22689
saudkhanzada wants to merge 1 commit into
nodejs:masterfrom
saudkhanzada:master

Conversation

saudkhanzada commented Sep 4, 2018
edited
Loading

Copy link
Copy Markdown

replaces assert.throws() with common.expectsError() to check error code
and error type in parallel/test-buffer-alloc.js

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

replaces assert.throws() with common.expectsError() to check error code
and error type in parallel/test-buffer-alloc.js
nodejs-github-bot added the test Issues and PRs related to the tests. label Sep 4, 2018

Trott commented Sep 4, 2018

Copy link
Copy Markdown
Member

BridgeAR left a comment

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

There is no need to use common.expectsError() to do this. assert.throws() is also able to do that. Therefore the message is a bit off. I suggest to rephrase to:
test: check for error codes in test-buffer-alloc.js

Otherwise LGTM

Trott commented Sep 5, 2018
edited
Loading

Copy link
Copy Markdown
Member

There is no need to use common.expectsError() to do this.

@BridgeAR The reason to use common.expectsError() is so that it can be cherry-picked into the 8.x-staging branch rather than requiring a backport.

Once 10.x is the oldest supported version, we can likely get rid of common.expectsError() in favor of assert.throws(). (We'll need to refactor cases where common.expectsError() returns a function, but it should be do-able.)

BridgeAR added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Sep 5, 2018
assert.throws(() => b.write('', 2048), RangeError);
common.expectsError(
() => b.write('', 2048),
{

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

nit: Since this error object is used multiple times in the test, it can be stored in a const.

Trott commented Sep 8, 2018

Copy link
Copy Markdown
Member

Trott commented Sep 8, 2018

Copy link
Copy Markdown
Member

Trott commented Sep 8, 2018

Copy link
Copy Markdown
Member

refack commented Sep 8, 2018

Copy link
Copy Markdown
Contributor

The reason to use common.expectsError() is so that it can be cherry-picked into the 8.x-staging branch rather than requiring a backport.

I remember we used to use common.expectsError for checking NodeErrors that have an error code, while assert.throws was the legacy usage. And we used that distinction to track where we still throw "old" errors.
Was that effort completed?

BridgeAR commented Sep 8, 2018

Copy link
Copy Markdown
Member

@refack assert.throws() became significantly more powerful in the meanwhile. It now behaves very similar to common.expectsError(). But @Trott is correct that these changes were not yet backported to 8 and it's easier to backport everything with the current notation until those features landed in 8 as well.

Trott pushed a commit to Trott/io.js that referenced this pull request Sep 8, 2018
replaces assert.throws() with common.expectsError() to check error code
and error type in parallel/test-buffer-alloc.js

PR-URL: nodejs#22689
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

Trott commented Sep 8, 2018

Copy link
Copy Markdown
Member

Landed in 9782ce2.

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/.)

Trott closed this Sep 8, 2018
targos pushed a commit that referenced this pull request Sep 9, 2018
replaces assert.throws() with common.expectsError() to check error code
and error type in parallel/test-buffer-alloc.js

PR-URL: #22689
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
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.

9 participants


Back | FazBrowse Home | New Git URL