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: fix error when foo in path to git clone #14506

Closed
wants to merge 5 commits into from

Conversation

SwimmingSage
Copy link
Contributor

@SwimmingSage SwimmingSage commented Jul 26, 2017

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 nodejs-github-bot added the test Issues and PRs related to the tests. label Jul 26, 2017
@@ -67,5 +67,5 @@ common.expectsError(() => {
// The stackFrameFunction should exclude the foo frame
assert.throws(
function foo() { assert.fail('first', 'second', 'message', '!==', foo); },
(err) => !/foo/m.test(err.stack)
(err) => !/foo(?!\/)/m.test(err.stack)
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

@SwimmingSage SwimmingSage Jul 26, 2017

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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
Member

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Ok, will do, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

@vsemozhetbyt vsemozhetbyt added the assert Issues and PRs related to the assert subsystem. label Jul 26, 2017
@@ -67,5 +67,5 @@ common.expectsError(() => {
// The stackFrameFunction should exclude the foo frame
assert.throws(
function foo() { assert.fail('first', 'second', 'message', '!==', foo); },
(err) => !/foo/m.test(err.stack)
(err) => !/\sat\sfoo/.test(err.stack)
Copy link
Contributor

Choose a reason for hiding this comment

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

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

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, I can do that, thank you for the feedback again

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.

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

@SwimmingSage
Copy link
Contributor Author

@addaleax Done, thank you for the suggestion!

@vsemozhetbyt
Copy link
Contributor

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

@addaleax
Copy link
Member

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

@vsemozhetbyt
Copy link
Contributor

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

@SwimmingSage
Copy link
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

@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jul 27, 2017

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

@Trott
Copy link
Member

Trott commented Jul 27, 2017

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

@addaleax
Copy link
Member

Landed in 1424e9e, thanks for the contribution!

@addaleax 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 <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
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 <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
@addaleax addaleax mentioned this pull request Aug 2, 2017
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