-
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: refactors test-tls-client-verify #10051
Conversation
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 for the contribution! The common.mustCall()
stuff can be a bit tricky the first time one comes across it. I think this isn't quite correct.
If you want to isolate it, feel free to pull it out of this PR (just leaving the const
and strictEqual()
stuff) and put it in another PR where it can be discussed in isolation.
Or if you feel like you have a good handle on it, go for fixing it here!
And if you're totally confused, feel free to hit me up (or anyone else, really) in email or IRC or Slack or whatever.
if (!tcase) return; | ||
const tcase = testCases[testIndex]; | ||
if (!tcase) { | ||
common.mustCall(function() { |
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 doesn't look right. If you put common.mustCall()
inside a conditional, then the function won't be required to be called unless the conditional is true. But this is an immediately-invoked function, so the common.mustCall()
seemingly serves no purpose here. Maybe what is meant is for thisMustRunOnce = common.mustCall(function() {...});
to be outside the conditional and then inside the conditional: thisMustRunOnce()
.
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 for the detailed feedback @Trott, it is very appreciated. Specifically, the final request was to refactor the process.exit into a common.mustCall instead. I see how it doesn't make sense to have it inside the conditional. Would it be better to revert the final task back to using the process.exit call, simply remove the mustCall from the conditional, or to refactor as a function using mustCall outside the conditional as suggested?
I read through the code for mustCall and I understand what it's doing, I'm just not 100% certain I fully grok the intention of its usage in testing. Thanks!
Swaps var -> const/let assert.equal becomes assert.strictEqual common.mustCall on single-use functions
@Trott, I reverted the final refactor of process.exit to the mustCall pattern (for now) and changed the commit message accordingly. Thanks for the help on it. |
LGTM if CI is ✅ |
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
Landed in fd6999e, thanks for the contribution! |
Swaps var -> const/let assert.equal becomes assert.strictEqual common.mustCall on single-use functions PR-URL: #10051 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Swaps var -> const/let assert.equal becomes assert.strictEqual common.mustCall on single-use functions PR-URL: #10051 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Swaps var -> const/let assert.equal becomes assert.strictEqual common.mustCall on single-use functions PR-URL: nodejs#10051 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Swaps var -> const/let assert.equal becomes assert.strictEqual common.mustCall on single-use functions PR-URL: #10051 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Swaps var -> const/let assert.equal becomes assert.strictEqual common.mustCall on single-use functions PR-URL: #10051 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Swaps var -> const/let assert.equal becomes assert.strictEqual common.mustCall on single-use functions PR-URL: #10051 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
test
Description of change
Refactor of test-tls-client-verify for NINA Code and Learn