-
Notifications
You must be signed in to change notification settings - Fork 30.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
improve the structure of the test-event-emitter-num-args
file and use the node test runner
#56671
improve the structure of the test-event-emitter-num-args
file and use the node test runner
#56671
Conversation
refacotr the structure of the `test-event-emitter-num-args` test file to improve its readability, use the node test runner and avoid collecting data and asserting it all in one go
2cb0bd3
to
4dcda1a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56671 +/- ##
==========================================
- Coverage 89.21% 89.20% -0.01%
==========================================
Files 662 662
Lines 191893 191934 +41
Branches 36936 36948 +12
==========================================
+ Hits 171189 171222 +33
- Misses 13541 13542 +1
- Partials 7163 7170 +7 |
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.
In my opinion it increases the mental overhead and reduces readability instead of improving it.
Hey @lpinca 🙂, thanks for having a look Is there something specific that you find reduces readability and increases mental overhead that I maybe could improve on? |
|
That's super interesting, thanks a lot! I'll have a good read! Naively I thought that
Yeah I agree with that one, initially I had something like |
Adding to @nodejs/tsc agenda because I think we need a TSC ruling on the debate or whether to restructure these tests around node:test so we don't have to fight the battle file by file. |
FWIW, I think the original test is more readable here. Not because of There are other tests which I think can benefit from this type of refactor more. Specifically, tests that spawn multiple child processes at the same time. I recently performed a couple of those updates in 93c15bf and 7e08cca. Other candidates are things that the test runner already gives you out of the box such as a test runner (221040b) or mocking. I also think we could remove a lot of the |
avoid array spearing
fix linting issues
fix dumb mistake
Taking this back off the tsc-agenda. |
FWIW for this kind of cases, I think it would be better not to spawn multiple child processes in one file at all if it's possible. It's better to simply split them into one file per test case, which also helps isolating the tests (and when you only have one test case per file it's generally unnecessary to use When we squeeze too many test cases in one file, when one break only part of them locally one has to look for the cause of failure in a huge sea of logs that do not fit in the screen scroll limit (grouping them with |
You are entitled to your opinion, but please stop conflating people writing bad tests with people using a test runner. Every point you bring up about these tests has happened before the test runner existed and will continue to exist, including stuffing too many tests in a single file via block scopes or IIFEs. Quite frankly, it's extremely annoying, particularly when people have made efforts (0576deb, afaa14b) to improve the situation for people like you. |
@cjihrig ... who are you directing your comments to? |
The comment immediately preceding mine. |
On a related note, we have introduced an env variable to help with setting the optimal concurrency in #52177 – arguably using |
I am not sure if I was clear enough, to clarify, I was trying to say that there were bad tests and while it was not limited to
While this is true, I think
Not sure who I am being conflated with, but the issues you referenced seems to be caused by the practices I advise against here. I'm just advocating that instead of migrating existing tests blindly with |
This doesn't really address the debuggability problem, or it makes things worse because it continues to encourage grouping test cases in one file. On the other hand, the python test runner is already capable of running the tests in parallel. If we just isolate the each test case that spawn child processes into their own files, not only does it help with debuggability, we also get parallelism without the use of |
@cjihrig it was/is also frustrating/annoying seeing PRs being merged with the complicity of the If you as TSC members honestly think this PR and the others I have blocked are good for the project and a mass refactor is needed, then I think I no longer align with the project values, priorities, and vision, and I'll think about stepping down as a core contributor. |
I understand that. I am personally not advocating for a mass rewrite of all of our tests. I also think it is fine for some people to prefer using I just don't appreciate the framing of "Node's tests were great and this is ruining them." We have good and bad tests written using |
@dario-piotrowicz .... My apologies. I know you're a brand new contributor seeking to learn how to contribute to the project and that discussions like what you're seeing here among existing core contributors is both not helpful and actively discouraging of new contributions, and for that I apologize. There are other areas of the codebase that would likely be easier to contribute to and I'll help you identify those. In the meantime I would recommend just abandoning this PR. |
I also want to apologize for hijacking the thread a bit to discuss about |
No need to apologize, thanks for backing my changes up 😊 Hopefully I'll have better luck with my next contribution attempt 😄🤞 |
Thanks! 🫶 Again no need to apologize, I naively thought using Anyways thanks a lot for the extra context! is very much appreciated 🙂 |
Closing the issue as per the above conversation, thanks y'all for having a look, I hope I didn't waste anyone too much time here 👋 |
this PR includes a very minor refactoring of the
test-event-emitter-num-args
file, mostly for improving readability and avoiding the pattern of collecting values and assert them all in one go