-
-
Notifications
You must be signed in to change notification settings - Fork 32k
test: add --test-files-glob flag #58860
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
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
3ceac62
to
cc36ffe
Compare
cc36ffe
to
b5c7e5f
Compare
Just adding tests now that I forgot for the changed test-coverage behaviour. |
Thanks for the PR can you add a empty line at the of the fixtures? |
Yeah I was wondering about that - my editor is using the top-level [{test/fixtures,deps,tools/eslint/node_modules,tools/gyp,tools/icu,tools/msvs}/**]
insert_final_newline = false Should I also remove the js fixtures from that glob? Or just manually add the newline and leave .editorconfig alone? |
b5c7e5f
to
b1fc7f1
Compare
I've just added the newlines manually - I will say it's out of scope to fix the editorconfig / fixture files (that could be a lit-fix for someone else I think). I've also fixed the js lint and commit message failing runs, and added test for the coverage stuff that the flag affects. |
How is different from users passing the positional glob argument? |
In short: it's an option instead of positional, which sounds a bit stupid but actually solves some problems. Because the cli splits argv and execArgv when the first positional is hit, flags need to come before positionals. I mentioned that it seems duplicated in the comment on #51384 and suggested alternatives in another related ticket, but ultimately it provides a solution (even if only until a better one comes along) to 2 things:
So it largely serves the same purpose, but as an option instead of positional it means you can do something like default the glob to I'm open to other possible solutions, I just wanted to get something in and working but I think this also brings it more inline to how people are familiar with using test runners (mocha, vite, deno, etc). Or rather, the original proposed solution on #51384 that I created a different branch for was closer to that (simply continuing to parse cli flags after seeing positionals) but I felt that was too disruptive a change, but I'd honestly prefer that option. My expectation (possibly incorrectly) is that |
b1fc7f1
to
99b7270
Compare
Actually fixed the commit message this time, and ran core-validate-commit to tripple check. |
Actually to expand on the above reasoning: The original idea was to continue to parse node flags after positionals when
For example, with an npm script So the core issue is not that positionals have to come after flags, but that there is no other way to override the default glob other than positionals. So by providing that as an option, the npm script would then be |
I'm not sure why some actions appear to be failing, am I not able to run them on my fork for testing? |
99b7270
to
28a0fa8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58860 +/- ##
==========================================
- Coverage 90.09% 89.56% -0.54%
==========================================
Files 640 640
Lines 188450 188458 +8
Branches 36966 36664 -302
==========================================
- Hits 169789 168790 -999
- Misses 11364 12333 +969
- Partials 7297 7335 +38
🚀 New features to boost your workflow:
|
Not sure why codecov is reporting that check as uncovered, I wrote tests specifically for it. Grep'd the logs, looks like all possible branches are either already covered, or covered by one of the 2 new tests. Maybe because it's not rebased off upstream/main any more - will rebase again just in case. |
28a0fa8
to
00192a6
Compare
src/node_options.cc
Outdated
AddOption("--test-files-glob", | ||
"set the default glob pattern for matching test files (default: " | ||
"'**/{test,test/**/*,test-*,*[._-]test}.{<extensions>}' where " | ||
"<extensions> is 'js,mjs,cjs' or 'js,mjs,cjs,ts,mts,cts' when using" | ||
" --experimental-strip-types)", | ||
&EnvironmentOptions::test_files_glob, | ||
kAllowedInEnvvar, | ||
OptionNamespaces::kTestRunnerNamespace); |
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.
AddOption("--test-files-glob", | |
"set the default glob pattern for matching test files (default: " | |
"'**/{test,test/**/*,test-*,*[._-]test}.{<extensions>}' where " | |
"<extensions> is 'js,mjs,cjs' or 'js,mjs,cjs,ts,mts,cts' when using" | |
" --experimental-strip-types)", | |
&EnvironmentOptions::test_files_glob, | |
kAllowedInEnvvar, | |
OptionNamespaces::kTestRunnerNamespace); | |
AddOption("--test-files-glob", | |
"set the default glob pattern for matching test files", | |
&EnvironmentOptions::test_files_glob, | |
kAllowedInEnvvar, | |
OptionNamespaces::kTestRunnerNamespace); |
The man needs to be updated too https://github.com/nodejs/node/blob/main/doc/node.1 |
Awesome, thanks. I don't think I knew node had a manpage... It's also not clear in the manpage which options that take an argument should be documented as such - it does not appear that every option taking an argument has an associated arg, so I went with copying the style of the nearest similar option. I would have assumed every option that takes an argument should be shown as such but maybe there are reasons not to. Happy to change it. |
Overrides the default `kDefaultPattern` for test file globs to allow for default file pattern matching, while still allowing other options or single, targeted file names for testing. This also might resolve issues with the defaults when using strip-types since the defaults can, currently, only be overridden using the positional `arguments` (see nodejs#56546). Fixes: nodejs#51384 Ref: nodejs#56546
00192a6
to
8f662d1
Compare
test: add --test-files-glob flag
Overrides the default
kDefaultPattern
for test file globs to allow fordefault file pattern matching, while still allowing other options or
single, targeted file names for testing.
This also might resolve issues with the defaults when using strip-types
since the defaults can, currently, only be overridden using the positional
arguments
(see #56546).Fixes: #51384
Ref: #56546
I believe this is a notable-change, I'll leave that up the reviewers though.
I also considered modifying the arg parser when the
--test
flag is present to continue parsing options that come after positionals.I think it's still (maybe) a decent solution (even if it behaves differently than other commands) since the test positionals are globs instead of files (like most other commands).
Happy to cleanup and push that up alternatively if that's preferred, or try something else if neither work - would like to resolve the current issues so that the default runner is a drop-in replacement for everything else.
Also note: still getting #44003 locally, I believe the solution is to enable another interface but I didn't dig too far into it, admittedly.