-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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: use countdown utility #32224
test: use countdown utility #32224
Conversation
I’m not sure that this actually makes the code easier to understand… |
I know @jasnell wrote it and likes it, so I'm always hesitant to express the opinion, but I dislike using the Countdown() abstraction in tests in most cases. Tests are the one place where readability is almost always more important than avoiding redundant code. As @addaleax notes, this doesn't make the test more readable. |
test/parallel/test-https-agent.js
Outdated
@@ -57,7 +61,8 @@ server.listen(0, function() { | |||
}, function(res) { | |||
res.resume(); | |||
assert.strictEqual(res.statusCode, 200); | |||
if (++responses === N * M) server.close(); | |||
++responses; |
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.
By adding the countdown you can eliminate the responses counter and the process.on('exit') check
It's not always about making the code more understandable... this doesn't make it less understandable either. There is Do-thing-when-X-events-happen logic all over our tests and it has been done inconsistently and in some cases incorrectly. Countdown has allowed us to unify that logic. I'd be a strong -1 on going back to having every test implementing their own countdown logic. |
|
@HarshithaKP A bit of both. Usually, the My preference would be to not go ahead with this. |
Closing based on the feedback. |
Refs: #32082 (comment)
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes