-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Conversation
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"
test/parallel/test-assert-fail.js
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do, thanks!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
test/parallel/test-assert-fail.js
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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*
😄
@addaleax Done, thank you for the suggestion! |
@addaleax is this |
@vsemozhetbyt Aaaah sorry yes, it should get the |
@SwimmingSage Thank you for the patience and sorry for all the nudging. Can you add the |
@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 |
Two windows failures due to |
@vsemozhetbyt Yes, unfortunately that test seems to be in perma-failure mode right now. #14507 |
Landed in 1424e9e, thanks for the contribution! |
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]>
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]>
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), orvcbuild test
(Windows) passesAffected core subsystem(s)
test