-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
test: refactor test for net listen on fd0 #10025
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
Conversation
test/parallel/test-net-listen-fd0.js
Outdated
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 think you could get rid of the exit listener if you assert in the error callback that e.code can only be EINVAL or ENOTSOCK
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.
@santigimeno do you suggest to do something like:
.on('error', common.mustCall(function(e) {
switch (e.code) {
case 'EINVAL':
case 'ENOTSOCK':
assert(e instanceof Error);
break;
}
santigimeno
left a comment
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 with a suggestion
test/parallel/test-net-listen-fd0.js
Outdated
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.
Can you capitalize and punctuate the comment please.
a3d0886 to
dab7b0c
Compare
|
Rebased with suggestions from @cjihrig and @santigimeno |
test/parallel/test-net-listen-fd0.js
Outdated
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 seems incorrect to me. The previous behavior ran the assertion no matter what. The new behavior guarantees that an error is emitted, but not that it is the correct type. What if you just did:
assert(e instanceof Error);
assert(['EINVAL', 'ENOTSOCK'].includes(e.code));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.
@cjihrig way better, I like it, just rebased with your suggestions
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler
dab7b0c to
7255098
Compare
cjihrig
left a comment
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 pending CI
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler
PR-URL: #10025
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
|
Landed in 1d766b8. Thank you for the PR and for participating in the code-and-learn! |
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler
PR-URL: #10025
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler
PR-URL: nodejs#10025
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler
PR-URL: nodejs#10025
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler
PR-URL: #10025
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
test, net
Description of change
Replace var to const/let, use common.mustCall on callbacks and move
process.on('exit') to the .on('error') handler