-
-
Notifications
You must be signed in to change notification settings - Fork 36.5k
test_runner: match dotfiles in default coverage exclude #63401
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
Open
semimikoh
wants to merge
1
commit into
nodejs:main
Choose a base branch
from
semimikoh:test_runner/coverage-dotfile-exclude
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+59
−31
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/fixtures/test-runner/coverage-default-exclusion/test/.dotfile.cjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| const test = require('node:test'); | ||
| const assert = require('node:assert'); | ||
| const { foo } = require('../logic-file.js'); | ||
|
|
||
| test('foo returns 1 from a dotfile test', () => { | ||
| assert.strictEqual(foo(), 1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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't we pass the same options and thus and use the same matcher for both or no?
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.
Intentional —
relativeneedsdot: trueso the default exclude globs match project dotfiles liketest/.foo.test.js(the point of this PR), butabsolutedeliberately leaves it off. Enablingdot: truethere could make a glob unintentionally match a dot segment that shows up in the absolute path for unrelated reasons (e.g. an OS temp dir liketest/.tmp.0), which isn't something the user's pattern was written to target.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.
Shouldn't they be on par? As in, if we are changing this to include dots locally, wouldn't it make sense to also include them globally?
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.
Not quite symmetric on purpose — I actually tested this by flipping
absoluteto usedot: truetoo and running it against the exacttest/**/*default pattern.Node's own test runner puts
NODE_TEST_TMPDIRunder a dot-prefixed directory (test/.tmp.<n>/, seetest/common/tmpdir.js). Withdot: trueonabsolute,**is allowed to traverse into.tmp.<n>, so the defaulttest/**/*exclude pattern ends up matching the absolute path of any file running under that tmp dir — e.g..../test/.tmp.0/logic-file.jsmatchestest/**/*.js, even thoughlogic-file.jsis a normal source file that should stay covered.Since basically every Node test that uses a tmpdir runs under
test/.tmp.N/, makingabsolutesymmetric withdot: truewould cause widespread false-exclusions whenever coverage runs inside the Node source tree itself.relativeonly needsdot: truefor*to match a leading dot in the basename (e.g..foo.test.js); it doesn't need**to traverse arbitrary dot directories the wayabsolutewould.