-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 error validation to assert.throws calls #11253
Conversation
I'd be really surprised if (In this case, |
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.
LGTM if CI is green. Definitely +1 on the regular expressions. Thanks for the contribution!
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.
Did this pass make test
for you locally?
EDIT: Nevermind, I see this is a pummel test.
test/pummel/test-crypto-dh.js
Outdated
function() { | ||
crypto.getDiffieHellman('unknown-group'); | ||
}, | ||
/^Unknown group$/, |
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.
I don't think these regular expressions will work. I think you need to include the error type as well. In this case:
/^Error: Unknown group$/
test/pummel/test-crypto-dh.js
Outdated
'crypto.getDiffieHellman(\'unknown-group\') ' + | ||
'failed to throw the expected error.' | ||
); | ||
assert.throws( | ||
function() { | ||
crypto.getDiffieHellman('modp1').setPrivateKey(''); | ||
}, | ||
/^crypto\.getDiffieHellman\(\.\.\.\)\.setPrivateKey is not a function$/, | ||
/^TypeError: crypto\.getDiffieHellman\(\.\.\.\)\.setPrivateKey/ + |
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.
I don't think this does what you're attempting to do. You'll probably have to use the RegExp()
constructor here and build the regex out of strings.
@cjihrig ... PTAL |
test/pummel/test-crypto-dh.js
Outdated
function() { | ||
crypto.getDiffieHellman('modp1').setPrivateKey(''); | ||
}, | ||
new RegExp(/^TypeError: crypto\.getDiffieHellman\(\.\.\.\)\./.source + |
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.
You can work with strings here. You don't need to pass regular expression literals to the RegExp
constructor.
Used regular expressions to validate error messages. Also added messages (third parameter) to the assert.throws calls.
@cjihrig ... PTAL |
I'm not sure why it's saying
When you check the details there are no indications of any tests failing. Could someone explain? |
PR-URL: #11253 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
The arm build bot just reports it's status incorrectly from time to time. All is good |
Landed in fcf3cbe |
PR-URL: #11253 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #11253 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #11253 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #11253 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #11253 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
I can't tell why the test was written that way in the first place, but it seems sufficient to check that setPrivateKey and setPublicKey are both undefined. Refs: nodejs/node-v0.x-archive#2638 Refs: nodejs#11253
I can't tell why the test was written that way in the first place, but it seems sufficient to check that setPrivateKey and setPublicKey are both undefined. Refs: nodejs/node-v0.x-archive#2638 Refs: #11253 PR-URL: #49404 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
I can't tell why the test was written that way in the first place, but it seems sufficient to check that setPrivateKey and setPublicKey are both undefined. Refs: nodejs/node-v0.x-archive#2638 Refs: #11253 PR-URL: #49404 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
I can't tell why the test was written that way in the first place, but it seems sufficient to check that setPrivateKey and setPublicKey are both undefined. Refs: nodejs/node-v0.x-archive#2638 Refs: nodejs#11253 PR-URL: nodejs#49404 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Used regular expressions to validate error messages.
Also added messages (third parameter) to the assert.throws calls.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test