-
Notifications
You must be signed in to change notification settings - Fork 30k
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: split up and refactor test-domain #13614
Conversation
I'm a bit ambivalent about this 🤔
Cons
Bottom lineMaybe add another test that asserts that a single domain can handle multiple |
291dd0a
to
cf4f46f
Compare
Fwiw I added a vaiant of the error-types test that throws all errors inside the same domain. |
One more for the pro list: Reduced likelihood of side effects between tests. I'm definitely +1 on this. |
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
/cc @misterdjules |
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 generally looks good to me. I like the idea of splitting the tests in separate files, so thanks for doing that!
In general, I'd like it if we kept, or improved on, the existing comments. They help people unfamiliar with the code base to understand the tests' purpose, behavior and internals.
I left a few questions as well. For instance, it seems that a test might have been lost in the transition, but I may have missed something too.
{ | ||
const d = new domain.Domain(); | ||
|
||
const bound = d.intercept(common.mustCall((data) => { |
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.
Instead of removing them, keeping (or improving on) the comments present in the previous version of this test would help understand it.
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.
The problem I see with the previous comments regarding this test (and some of the others) is that they seemed more like API documentation rather than actually helping to explain what the test does. In this case, I hope it becomes much more visible what each part of the test does by identifying the groups of code that test a single piece of the functionality.
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.
Some of these comments describe the intention of these tests. For instance:
// catch thrown errors no matter how many times we enter the event loop [...]
Looking at the new version of that test in test-domain-implicit-binding.js
, it's not clear why the error is thrown from a nested async operation nested several layers deep, and so it's not clear to the person who hasn't written this test whether it even makes sense to keep this test.
I still think it would be worth it to keep those comments.
@@ -0,0 +1,23 @@ | |||
'use strict'; |
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.
What is the difference between this test and test/parallel/test-domain-error-types.js
?
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.
The only difference is that one of the tests emits the errors on the same domain object, because that was requested here. I’ve added comments referencing the other test file in each of them.
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.
Great, thanks!
|
||
const d = new domain.Domain(); | ||
|
||
assert.strictEqual(d.run(() => 'return value'), |
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.
Here too, keeping or improving on the comments of the previous version of this test would help understand its purpose.
// this only uses implicit binding, except for the first function | ||
// passed to d.run(). The rest are implicitly bound by virtue of being | ||
// set up while in the scope of the d domain. | ||
d.run(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.
Was this test removed by this change, if so, why?
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.
Yes, that was an oversight. I added it as test-domain-implicit-binding.js
.
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.
Excellent, thank you!
0655c38
to
3ccee05
Compare
Does anybody mind if I land this next-week-ish? |
This needs a rebase. Otherwise I think this could land as it. |
The comments were addressed as far as I see it. There was no response for a long time. Please have another look.
Ping @addaleax |
Ping @addaleax once more |
3ccee05
to
7b1ae46
Compare
@BridgeAR … rebased. :) |
Trying CI again on windows: https://ci.nodejs.org/job/node-test-commit-windows-fanned/12048/ |
@addaleax seems like there are related failures.
|
7b1ae46
to
87b083f
Compare
Rebased, new CI to see whether errors persist: |
All windows machines returned:
P.S. Seems like the wWindows |
87b083f
to
0f5c8a1
Compare
Split up test-domain into multiple, more focused test files and use more modern JS inside of them.
0f5c8a1
to
ceca532
Compare
Okay, I’ve relaxed the error message a bit. This is not an |
Landed in 1a2f579 |
Split up test-domain into multiple, more focused test files and use more modern JS inside of them. PR-URL: #13614 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Split up test-domain into multiple, more focused test files and use more modern JS inside of them. PR-URL: #13614 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Split up test-domain into multiple, more focused test files and use more modern JS inside of them. PR-URL: nodejs/node#13614 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Split up test-domain into multiple, more focused test files and use more modern JS inside of them. PR-URL: #13614 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Split up test-domain into multiple, more focused test files and use more modern JS inside of them. PR-URL: #13614 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Split up test-domain into multiple, more focused test files and use more modern JS inside of them. PR-URL: #13614 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Split up test-domain into multiple, more focused test files and use more modern JS inside of them.
/cc @nodejs/testing