test: refactor test for net listen on fd0#10025
test: refactor test for net listen on fd0#10025julianduque wants to merge 1 commit intonodejs:masterfrom
Conversation
test/parallel/test-net-listen-fd0.js
Outdated
There was a problem hiding this comment.
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.
@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;
}
test/parallel/test-net-listen-fd0.js
Outdated
There was a problem hiding this comment.
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.
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.
@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
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