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

test: fix error when foo in path to git clone by SwimmingSage · Pull Request #14506 · nodejs/node · GitHub

/ node Public

test: fix error when foo in path to git clone - #14506

Closed
SwimmingSage wants to merge 5 commits into
nodejs:masterfrom
SwimmingSage:my-branch
Closed

test: fix error when foo in path to git clone#14506
SwimmingSage wants to merge 5 commits into
nodejs:masterfrom
SwimmingSage:my-branch

Conversation

SwimmingSage commented Jul 26, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

I fixed an error that occurred in the test case of the file
test/parallel/test-assert-fail.js when foo was in the path to
the git clone. This occurred due to a regex that looked only for the
word foo, and so it was updated to not look for foo/, but only
foo. This way it won't go off from foo being in the path to the
git clone.

What this part of the test verifies is that the last argument
to assert.fail in
function foo() { assert.fail('first', 'second', 'message', '!==', foo); },
(the , foo one) is not ignored. If it is ignored an error would appear
stating at foo near the top of the error message, thus if the path
contains foo it will not trigger the error message

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

I fixed an error that occured in the test case of the file
test/parallel/test-assert-fail.js when foo was in the path to
the git clone. This occured due to a regex that looked only for the
word foo, and so it was updated to not look for foo/, but only
foo. This way it won't go off from foo being in the path to the
git clone"
nodejs-github-bot added the test Issues and PRs related to the tests. label Jul 26, 2017
Comment thread test/parallel/test-assert-fail.js Outdated
assert.throws(
function foo() { assert.fail('first', 'second', 'message', '!==', foo); },
(err) => !/foo/m.test(err.stack)
(err) => !/foo(?!\/)/m.test(err.stack)

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 is enough to cover /path/with/foo/node, but it wouldn’t catch e.g. /path/with/foo-bar/node (or, for that matter, Windows paths that use \), right?

It still looks good to me as it’s strictly an improvement, but maybe there are better options.
It might be enough if the regex checks for (whitespace)at foo , because that’s how the function names show up?

SwimmingSage Jul 26, 2017
edited by Trott
Loading

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

Ok, I was unsure of what this error would actually look like, as the error message I received was in this block:

AssertionError [ERR_ASSERTION]: message
    at tryBlock (assert.js:595:5)
    at innerThrows (assert.js:614:18)
    at Function.throws (assert.js:641:3)
    at Object.<anonymous> (/Users/SwimmingSage/githubProjects/**foo**/node/test/parallel/test-assert-fail.js:68:8)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Function.Module.runMain (module.js:609:10)

So I simply tried to catch for that case, would you happen to know by chance where in that block foo would be mentioned if an actual error went off? I didn't want to be too specific as I was worried about interfering when there actually should be an error. But I definitely agree that this can be made more specific

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

Oh sorry, I just saw that you did in fact mention that, my apologies, I will edit it for:

(whitespace)at foo

Thank your for your feedback!

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

So I simply tried to catch for that case, would you happen to know by chance where in that block foo would be mentioned if an actual error went off?

What this part of the test verifies is that the last argument to assert.fail in function foo() { assert.fail('first', 'second', 'message', '!==', foo); }, (the , foo one) is not ignored. If you remove that bit, you’ll see something like an additional at foo line near the top.

(Since this is obviously not obvious, you could add a comment here that explains what the test does as well?)

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

Ok, will do, thanks!

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

BTW, it seems that /m flag is redundant here, as it is useful only if ^$ symbols are used.

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

Ok, I'll get rid of that then, thank you for the feedback!

vsemozhetbyt added the assert Issues and PRs related to the assert subsystem. label Jul 26, 2017
Comment thread test/parallel/test-assert-fail.js Outdated
assert.throws(
function foo() { assert.fail('first', 'second', 'message', '!==', foo); },
(err) => !/foo/m.test(err.stack)
(err) => !/\sat\sfoo/.test(err.stack)

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

Maybe /\sat\sfoo\b/ to be extra careful?

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

Yeah, I can do that, thank you for the feedback again

addaleax 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

Thanks!
One tiny suggestion for even more strictness: start with ^\s* 😄

Copy link
Copy Markdown
Contributor Author

@addaleax Done, thank you for the suggestion!

Copy link
Copy Markdown
Contributor

@addaleax is this ^ OK without the /m flag? Should we check only the first stack line?

Copy link
Copy Markdown
Member

@vsemozhetbyt Aaaah sorry yes, it should get the /m flag again.

Copy link
Copy Markdown
Contributor

@SwimmingSage Thank you for the patience and sorry for all the nudging. Can you add the /m flag again?

Copy link
Copy Markdown
Contributor Author

@vsemozhetbyt Yeah, I just did, and no worries, this is my first time helping out on an open source project and I greatly appreciate the feedback

Copy link
Copy Markdown
Contributor

vsemozhetbyt commented Jul 27, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Two windows failures due to inspector/test-inspector-stop-profile-after-done (seems unrelated?)

Trott commented Jul 27, 2017

Copy link
Copy Markdown
Member

Two windows failures due to inspector/test-inspector-stop-profile-after-done (seems unrelated?)

@vsemozhetbyt Yes, unfortunately that test seems to be in perma-failure mode right now. #14507

Copy link
Copy Markdown
Member

Landed in 1424e9e, thanks for the contribution!

addaleax closed this Jul 30, 2017
addaleax pushed a commit that referenced this pull request Jul 30, 2017
I fixed an error that occured in the test case of the file
test/parallel/test-assert-fail.js when foo was in the path to
the git clone. This occured due to a regex that looked only for the
word foo, and so it was updated to not look for foo/, but only
foo. This way it won't go off from foo being in the path to the
git clone

PR-URL: #14506
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
addaleax pushed a commit that referenced this pull request Aug 1, 2017
I fixed an error that occured in the test case of the file
test/parallel/test-assert-fail.js when foo was in the path to
the git clone. This occured due to a regex that looked only for the
word foo, and so it was updated to not look for foo/, but only
foo. This way it won't go off from foo being in the path to the
git clone

PR-URL: #14506
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
addaleax mentioned this pull request Aug 2, 2017
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

assert Issues and PRs related to the assert subsystem. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL