-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
[node:test] Infinite loop occurs when files
is empty
#48823
Comments
I am not sure I would consider this a bug, you should either specify |
Does it mean that the
Would you prefer to modify the document in that case?
|
the file calling |
So, I think |
why? it is still correct |
I think So I think it should state that it cannot be omitted instead of |
How do I call the default file pattern like |
|
When I run So, I think Could you please exec this code? $ node -v
v20.4.0
$ tree
.
└── run.js
$ cat run.js
require('node:test').run({ files: undefined }).compose(require('node:test/reporters').tap).pipe(process.stdout)
# this code occurs infinite loop
$ node run.js
This happens with any file name. |
Is that mean that 'node run.js' (which files: undefined) is equal to 'node --test run.js', as @koh110 explained? I don't think that such 'expected' behaviour is really expected. We should have note in docs, or some asserts in test-runner code to brake the loop. |
@koh110 if you experience an infinate loop - that means the file called by |
@MoLow It occurs with any file name. Could you please run this sample? |
let testFiles = files ?? createTestFileList(); But function createTestFileList() {
const cwd = process.cwd();
const hasUserSuppliedPattern = process.argv.length > 1;
const patterns = hasUserSuppliedPattern ? ArrayPrototypeSlice(process.argv, 1) : [kDefaultPattern];
So, I think |
you should not be running |
@MoLow It gives the same result without |
One way we could address this with a semver major change is to make |
@cjihrig Do you mean that the default file pattern like |
Correct. Although we could expose an API to get that list. |
@cjihrig Thanks. I understand thanks to your answer. Should I send a PR to require options.files in the docs? |
Making it a required argument would also require a code change, but first let's see how other collaborators feel. There isn't really a rush because it's a breaking change so it wouldn't be released until October anyway. |
OK, thanks. |
the next semver release will include glob support, and until we expose |
hoever we can easily detect if |
It's sounds good for me. If you give me the sample, I will make a PR.
|
I would like to work on this. |
It should not be required - it has a default value |
Version
v20.4.0
Platform
Darwin MacBook-Pro.local 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
This code occurs infinite loop.
How often does it reproduce? Is there a required condition?
everytime
What is the expected behavior? Why is that the expected behavior?
Default is written as
test runner execution model
. But it does not work.https://nodejs.org/api/test.html#runoptions
It seems that tests that are run during
node --test
should be run whenfiles
is empty.What do you see instead?
https://github.com/koh110/minimum-nodejs-test
Additional information
createTestFileList
gets its own file path.It seems that it have to exclude own file path when executing in
run
.node/lib/internal/test_runner/runner.js
Lines 90 to 92 in 9988130
node/lib/internal/test_runner/runner.js
Lines 473 to 477 in 9988130
The text was updated successfully, but these errors were encountered: