Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add a RegExp #10058

Closed
wants to merge 1 commit into from
Closed

test: add a RegExp #10058

wants to merge 1 commit into from

Conversation

zjyw
Copy link
Contributor

@zjyw zjyw commented Dec 1, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

Description of change

Add a RegExp as a second argument to assert.throws().

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Dec 1, 2016
@imyller imyller added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label Dec 1, 2016
@@ -4,5 +4,7 @@ const assert = require('assert');
const dns = require('dns');

// Should not raise assertion error. Issue #7070
assert.throws(() => dns.resolveNs([])); // bad name
assert.throws(() => dns.resolveNs('')); // bad callback
//assert.throws(() => dns.resolveNs([]), /^\"name\" argument must be a string$/); // bad name
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line was committed by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Thanks for catching it. Now it is fixed.

assert.throws(() => dns.resolveNs([])); // bad name
assert.throws(() => dns.resolveNs('')); // bad callback
assert.throws(() => dns.resolveNs([]), /"name" argument must be a string/); // bad name
assert.throws(() => dns.resolveNs(''), /"callback" argument must be a function/); // bad callback
Copy link
Member

Choose a reason for hiding this comment

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

These lines are longer than 80 characters, which is something we want to avoid – could you move the second argument to a new line (and align that below the first argument)?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're checking the entire error message, you can add ^ and $ to the regular expression as well.

@zjyw
Copy link
Contributor Author

zjyw commented Dec 6, 2016

thanks for the suggestions. made the changes.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

The changes LGTM but the commits should be squashed and a bit more descriptive.. for instance:

test: test error messages in test-dns-regress-7070.js

@@ -4,5 +4,14 @@ const assert = require('assert');
const dns = require('dns');

// Should not raise assertion error. Issue #7070
assert.throws(() => dns.resolveNs([])); // bad name
assert.throws(() => dns.resolveNs('')); // bad callback
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like some merge conflicts got through.

@zjyw
Copy link
Contributor Author

zjyw commented Dec 6, 2016

It took me several commits to get it right. I think it should be good now. Let me know if there is anything else I need to change.

assert.throws(() => dns.resolveNs([]), // bad name
/^Error: "name" argument must be a string$/);
assert.throws(() => dns.resolveNs(''), // bad callback
/^Error: "callback" argument must be a function$/);
Copy link
Member

Choose a reason for hiding this comment

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

@zjyw can you please add a final new line? The linter will fail without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah. just added it. thanks for pointing it out. i was wondering about it after my last commit.

@Fishrock123
Copy link
Contributor

dont-land-on-v7.x seems correct here. - nodejs/github-bot#100

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@Fishrock123 why this shouldn't land on v7.x ?

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@addaleax LGTY?

@targos
Copy link
Member

targos commented Dec 16, 2016

@lpinca The changes don't apply cleanly (even on master)

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@targos I see, the green merge button tricked me, thanks.

@zjyw
Copy link
Contributor Author

zjyw commented Dec 16, 2016

@targos I am new to the node.js change system. When you say it won't apply cleanly, do you mean the unit test will fail or something else?

@gibfahn
Copy link
Member

gibfahn commented Dec 16, 2016

@zjyw He means that there are merge conflicts when he tried to apply this PR as a series of patches (as described here). If you rebase against master it should fix the issues.

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

yes, lgtm!

@lpinca
Copy link
Member

lpinca commented Dec 16, 2016

@zjyw if you could rebase this PR against master and optionally squash your commits that would be awesome.

@Fishrock123
Copy link
Contributor

Next time please try to do a backport before removing the label, thanks.

This does not apply cleanly on v7.x

@targos
Copy link
Member

targos commented Dec 16, 2016

@Fishrock123 I tried and it does apply cleanly if the commits are squashed.
Maybe I don't understand correctly the purpose of the dont-land-on- labels. What I read is "do not land", as an imperative mood. When I put the label on a PR, it is to indicate that the commit should not go into that branch, even if it applies cleanly.

@zjyw
Copy link
Contributor Author

zjyw commented Dec 18, 2016

Rebased and squashed using 'git rebase -i HEAD~7'. Let me know if I did it right.

Add a RegExp as a second argument to assert.throws().
@targos
Copy link
Member

targos commented Dec 19, 2016

@zjyw it seems something went wrong. I went ahead and fixed it. Here is what I did, with the upstream remote pointing to this repo (nodejs/node):

  • git fetch upstream
  • git rebase -i upstream/master
  • Pick the first commit and squash the others:
    image
  • Fix the conflicts (just always kept the HEAD part) until the rebase is done.
  • make test to check everything is fine
  • git push --force-with-lease zjyw HEAD:master

@targos
Copy link
Member

targos commented Dec 19, 2016

@zjyw
Copy link
Contributor Author

zjyw commented Dec 19, 2016

@targos thanks for help!

@Trott
Copy link
Member

Trott commented Dec 22, 2016

CI failure on FreeBSD seems entirely unrelated to this change, but just to be sure...

CI: https://ci.nodejs.org/job/node-test-pull-request/5528/

Trott pushed a commit to Trott/io.js that referenced this pull request Dec 24, 2016
Add a RegExp as a second argument to assert.throws().

PR-URL: nodejs#10058
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@Trott
Copy link
Member

Trott commented Dec 24, 2016

Landed in be6de1a.
Thanks for the contribution! 🎉

@Trott Trott closed this Dec 24, 2016
targos pushed a commit that referenced this pull request Dec 26, 2016
Add a RegExp as a second argument to assert.throws().

PR-URL: #10058
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@MylesBorins MylesBorins mentioned this pull request Dec 27, 2016
evanlucas pushed a commit that referenced this pull request Jan 3, 2017
Add a RegExp as a second argument to assert.throws().

PR-URL: #10058
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
evanlucas pushed a commit that referenced this pull request Jan 4, 2017
Add a RegExp as a second argument to assert.throws().

PR-URL: #10058
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet