| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Review requested:
|
Sorry, something went wrong.
|
|
||
| These dependencies are: | ||
|
|
||
| - `node:async_hooks` |
There was a problem hiding this comment.
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).
Sorry, something went wrong.
There was a problem hiding this comment.
Sounds good to me, but before removing the rest, what's your reasoning for keeping only async_hooks here?
Sorry, something went wrong.
There was a problem hiding this comment.
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 😄
Sorry, something went wrong.
There was a problem hiding this comment.
Can you recommend changes to the text, please?
Sorry, something went wrong.
| - `node:child_process` | ||
| - `node:fs` | ||
| - ReadableStream in `node:streams` | ||
| - `node:vm` |
There was a problem hiding this comment.
I think the files listed in test/parallel/test-bootstrap-modules.js can be a good measure here.
Sorry, something went wrong.
There was a problem hiding this comment.
What do you mean? I don't follow
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
(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)
Sorry, something went wrong.
There was a problem hiding this comment.
Can you recommend changes to the text, please?
Sorry, something went wrong.
|
Some issues I've found with node:test that I think worth looking into before recommending using node:test.
|
Sorry, something went wrong.
Co-authored-by: Rafael Gonzaga <rafael.nunu@hotmail.com>
|
|
||
| ### Usage of `node:test` | ||
|
|
||
| It is optional to use `node:test` in tests outside of testing the `node:test` |
There was a problem hiding this comment.
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....
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
Can you recommend changes to the text, please?
Sorry, something went wrong.
I think people will have different opinions on this. When there are a number of tests in a single file and I am relying on the CI for some platform other than macOS I actually want to see everything that passes and fails before pushing up another commit. Another general solution is to not test multiple things in a single file.
The failures should be at the very bottom?
This drives me crazy as well. I'm not sure if this is something specific to Jenkins that can be fixed or what. I haven't noticed it in GitHub action for example. |
Sorry, something went wrong.
|
From a quick check, it does appear that Deno and Bun both use their own test runners in at least some places. Of course, I didn't check every test and I don't know what policies they might have in place around that. |
Sorry, something went wrong.
I certainly expect using a test runner to add overhead that isn't there when not using a test runner. A few things to note: this sounds like web frameworks claiming to be x% faster at serving an empty response, but this often goes away once any real logic is introduced. Also, the test runner bootstraps itself when the first test is run, so I would expect subsequent test() calls to be faster. |
Sorry, something went wrong.
It is indeed opinionated. I prefer to stop at the first failure, fix it, rerun, repeat.
Definitely.
I honestly don't care how other projects run their tests and I think there is nothing wrong with our tests. I actually think the way our tests are currently written and run is one of the best part of the project. No bullshit, only the strictly needed code and dependencies. I am very convinced that a refactor to use node:test is a mistake. What does this bring to the project? There are multiple comments here and in other threads with concerns and real downsides. What are are the upsides? No specific Node.js API? That's a lie, for example see #56027. More details in the tests? Comments work better. Instead of harmful refactors, I think that our time is better spent on investigating and fixing dozen of tests marked flaky and issues like #54918. |
Sorry, something went wrong.
|
@lpinca I've mentioned couple of upsides of using node:test using the last TSC meeting. I recommend watching it since it also includes several different opinions from other TSC members as well. |
Sorry, something went wrong.
There is a difference between running it on CI and locally. For example we use different output settings in the python test runner locally and in the CI as well. I think it would make more sense to align with what we do with the Python test runner: low-noise output when run locally, more details in the CI.
The logs are not, and are in the middle of a bunch of passing test descriptions that you need to ignore - and when you are debugging a test failures, you mostly care about the assertion failure and logs, not the test descriptions (especially when there's no requirement about writing good test descriptions and they might just be random words that people put together...). Also, this is assuming that only a single test is run. When multiple tests are failing during a run by the Python test runner, you are still going to have to scroll and fish out failure form pages of noise from later tests, instead of just looking at only relevant error information from all the tests that are failing. At the very least, is there e.g. an environment variable that allows us to skip the logs about successful tests? It can be opinionated but personally I find them rather counter productive especially when I put any logs in the tests to aid debugging. |
Sorry, something went wrong.
Isn't that going to be in conflict with the recommendation of:
? The more singled out tests we have, the more overhead we will introduce; but if we squeeze the tests in one file, the reporter will make the test failures harder to fish out from the noise? Also many core tests are just very light weight - they are core tests, after all, and many of them don't test complex operations but just trivial edge cases (validation errors, simple calls to deps, pure JS computations etc.). In many cases the biggest part of the overhead is the bootstrapping overhead and the actual tests actually take less time than the bootstrap itself. Of course there are also tests that are more complex and async e.g. the http tests, which I think might benefit from using node:test. But I think we should also have some guidelines about when to avoid using node:test on other smaller tests (e.g. many of the util tests). |
Sorry, something went wrong.
I'm not the person advocating for a massive refactor and never have been. I will say that I would not put that in the top 10 all time worst mistakes made by the project, or even top 3 in the past 6 months 😄
Yes. Some of the tests are currently written with many tests in the same file. We should aim to change that.
This. It would be nice to have more subtlety around this topic. I was mostly just commenting here because I think these threads are mixing valid feedback, personal opinions, and things presented as fact that are incorrect based on people's opinions. I'll stop now. |
Sorry, something went wrong.
|
@anonrig I've just finished watching it. The following arguments in favor of node:test are raised
I'm getting bored of repeating myself but don't add complexity where it is not needed, especially in tests. We only hurt ourselves with those refactors. |
Sorry, something went wrong.
I think maybe a good measure about this might be: only the people maintaining what the test is testing get to choose what format the test should be written in, and forbid test-only changes from PRs that don't simultaneously change the features that the test is testing (unless they obviously had many commits in said feature or they reach consensus about this if there are multiple people maintaining said feature). The reasoning is that those who maintain the feature being tested would be the ones impacted the most by the test change and they should have better judgement about whether the test format changes can make their life easier or harder. That's what I have been doing so far as well - if I am touching an existing test, I respect whatever the test format it is in and just follow it. But I otherwise would not author node:test tests by myself at this point because of the UX issues mentioned in #56027 (comment) , especially the noise about successful tests. I don't mind tests for things that I don't maintain to be rewritten since I normally don't break them anyway, and don't normally need to spend minutes fishing out useful information out of the noise from dozens of tests being broken in a single test run because I make a mistake in the implementation. And I trust people who maintain things that I am not familiar with to write better tests using node:test if they believe this makes their life eaiser. |
Sorry, something went wrong.
This is exactly what I want
I've seen other test runners with a reporter that outputs only on failure. I think that would be good here and addresses the issue Joyee raised (CI output is indeed quite long). Writing to stdout is also not free, so that should help with performance too.
I think the dot reporter won't have that issue.
Oof, yes, this is not ideal. |
Sorry, something went wrong.
Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
|
My personal experience with node:test in the core repo is that it outputs super long failures because a single failure is printed twice: #56316. I find this really hurts the experience. |
Sorry, something went wrong.
I absolutely do not want this in the strongest of terms. IMO this an atrocious DX. I do not have a Windows PC, which is the least reliable platform. Whenever there are cross-platform issues, it's always Windows. If CI stops on the first of 50 failures and I have to discover and fix them one by one, with CI taking 4 hours each run? Absolutely. Not. I would never send another PR again. |
Sorry, something went wrong.
|
These concerns seem very actionable though 🙂 I expect we could even fairly easily facilitate the kill-all-on-first-failure via a label (I think it shouldn't be the default though, and definitely not the only option). For the output noise, I don't know enough about test reporters, but if we can't configure an existing one for a quiet mode, could we fork one to facilitate it? |
Sorry, something went wrong.
|
|
||
| ### Usage of `node:test` | ||
|
|
||
| It is optional to use `node:test` in tests outside of testing the `node:test` |
There was a problem hiding this comment.
I have thought about this a bit, and I don't believe we should include this list.
Sorry, something went wrong.
There was a problem hiding this comment.
Fourth, if we are going to maintain a list of problematic things to test, then that list should probably be based on real problems that have been encountered
I agree about this statement. Let's wait for tomorrow's @nodejs/tsc meeting to add this.
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
|
@cjihrig are you against using the test runner itself in core? |
Sorry, something went wrong.
|
Not at all. I have been happily using it. |
Sorry, something went wrong.
There was a problem hiding this comment.
I just ran into https://ci.nodejs.org/job/node-test-commit-osx/63165/nodes=osx11-x64/testReport/junit/(root)/parallel/test_runner_module_mocking/
Compared to the other test that does not use node:test which was broken by the same reason (I think the main branch was broken, to reproduce just revert #56685):
I think output of node:test doesn't work with our Jenkins setups. I am blocking until this gets fixed somehow, either the Jenkins get fixed, or some workaround developed in the test runner, or at least amend this style guide to in a way that makes people write tests with node:test that do not produce a mess like https://ci.nodejs.org/job/node-test-commit-osx/63165/nodes=osx11-x64/testReport/junit/(root)/parallel/test_runner_module_mocking/ when it gets broken (this is a test runner test so I assume people knew what they doing when writing this test)
Sorry, something went wrong.
|
|
||
| ### Usage of `node:test` | ||
|
|
||
| It is optional to use `node:test` in tests outside of testing the `node:test` |
There was a problem hiding this comment.
| 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.
Sorry, something went wrong.
|
@joyeecheung it seems the experimental-permission bug is fixed on main. do you have any objections to removing your block, or do you have any recommendations on how to move forward? sorry, if i'm asking you to repeat. i'm trying to understand if there is a path forward. if not, i'm happy to close this pr. |
Sorry, something went wrong.
Glad to hear that there is a path forward. Let's wait for this awesome work. |
Sorry, something went wrong.
|
Yes the block is not specific to that test, for more examples see #56751 - this means that by using node:test there will be more and more stack traces looking like this pop up in Jenkins until it gets fixed. |
Sorry, something went wrong.
@joyeecheung Would you mind making a checklist/todo list for unblocking your review. I'll be happy to avoid wasting any of your time and complete them one by one when the time comes (along with the PRs that are completing them) |
Sorry, something went wrong.
|
Also, I think #56027 (comment) should be applied to prevent #56671 from happening again. If you really don't want to discourage modifying existing tests, then given the disruptions in output that can be caused by the new test reporter I think it warrants requirement of
(But in general I think substantially modifying tests purely for stylistic preference is just not a good idea, even if we have consensus about the style, because with our workflow that would just make backports harder - is letting in some style changes really that important compared to not impeding backports of important bug fixes and features?) |
Sorry, something went wrong.
Basically
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Adds a contributing guideline around the usage of node:test in tests/ folder. This pull-request is open as a result of last weeks TSC meeting.
Potentially unblocks #55716
cc @nodejs/tsc