Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
doc: add restrictions around node:test usage#56027
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -141,6 +141,27 @@ request. Interesting things to notice: | ||||||||||
| ## General recommendations | ||||||||||
| ### Usage of `node:test` | ||||||||||
| It is optional to use `node:test` in tests outside of testing the `node:test` | ||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have thought about this a bit, and I don't believe we should include this list.
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree about this statement. Let's wait for tomorrow's @nodejs/tsc meeting to add this.
| ||||||||||
| It is optional to use `node:test`in tests outside of testing the `node:test` | |
| It is discouraged to change existing tests that do not use `node:test`to use it, if there is no | |
| other better motivation. For newly added tests, is optional to use `node:test` in tests outside of testing | |
| the `node:test` |
I think we should mention that this is optional for newly added tests, to avoid encouraging people update existing tests solely for stylistic preferences like what happened in #56671. If people have to update it to use node:test based on stylistic preferences, IMO we should require them to break what it is testing deliberately in the PR and and run the CI both before and after the update, and see what the output looks like, to see if the use of node:test makes the output look worse than before, so that other people don't get hit by something like https://ci.nodejs.org/job/node-test-commit-osx/63165/nodes=osx11-x64/testReport/junit/(root)/parallel/test_runner_module_mocking/ afterwards.
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.
To be honest, async_hooks is probably the only thing I would include here (and I may update the test runner to migrate off of that in the future).
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.
Sounds good to me, but before removing the rest, what's your reasoning for keeping only async_hooks here?
cjihrigNov 27, 2024 •
edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
async_hooks actually changes how things work.
child_process and fs are so heavily depended on by other things that if they stop working we will definitely notice. The test runner also doesn't do anything "fancy" with them. You can also use the test runner without spawning child processes. But, child processes are only used by the test runner CLI, which Node core doesn't use at all anyway.
The only place the test runner uses a stream is for emitting events. If you were going to include that, you may as well include event emitter as well since it is part of streams.
The vm module is only used (directly) for evaluating snapshot files.
Also worth noting that the test runner is already used to test the test runner itself 😄
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 recommend changes to the text, please?
Uh oh!
There was an error while loading. Please reload this page.
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 the files listed in test/parallel/test-bootstrap-modules.js can be a good measure here.
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 do you mean? I don't follow
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.
It's probably worth adding anything related to the bootstrapping process to the list of things not to test with the test runner since I'm not sure you can be 100% certain the test runner itself is bootstrapped properly at that point.
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.
(Most of) the files listed there are essential parts of the Node.js functionality that are used more ubiquitously, hence more likely to be depended on by node:test itself (e.g. when we talk about node:async_hooks, that's actually built on top of other modules, not just itself, test/parallel/test-bootstrap-modules.js list a set of files that are generally used everywhere)
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 recommend changes to the text, please?
Uh oh!
There was an error while loading. Please reload this page.
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.
It seems important to document things like #52177 or otherwise we would see more flakes coming up once people start to spawn hundreds of child processes in parallel and overloading the machine using
spawnPromisified+node:test....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.
Agreed. Using the concurrency option is fine though unless you are specifically planning to spawn child processes. But that applies to things like
Promise.all()as well.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 recommend changes to the text, please?