-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test_runner: exclude test files from coverage by default #56060
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
Changes from 1 commit
4f5885e
4e2bdf6
1e5a29c
2692e5f
70be970
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,9 @@ const { | |
| readFileSync, | ||
| rmSync, | ||
| } = require('fs'); | ||
| const { setupCoverageHooks } = require('internal/util'); | ||
| const { setupCoverageHooks, isWindows, isMacOS } = require('internal/util'); | ||
| const { tmpdir } = require('os'); | ||
| const { join, resolve, relative, matchesGlob } = require('path'); | ||
| const { join, resolve, relative } = require('path'); | ||
| const { fileURLToPath } = require('internal/url'); | ||
| const { kMappings, SourceMap } = require('internal/source_map/source_map'); | ||
| const { | ||
|
|
@@ -42,6 +42,25 @@ const kLineEndingRegex = /\r?\n$/u; | |
| const kLineSplitRegex = /(?<=\r?\n)/u; | ||
| const kStatusRegex = /\/\* node:coverage (?<status>enable|disable) \*\//; | ||
|
|
||
| let minimatch; | ||
|
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. Is all of this to avoid the experimental warning? If so, maybe we should create a flag in the internal
Member
Author
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. yes it is 😞
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. It looks like
Member
Author
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. Ok, thanks, I'll take a look ASAP 🚀
Member
Author
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've just realised that in another part of the runner, we're using a different approach:
I'm just going to replace Edit: I think it's better to go with
Member
Author
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 moved module.exports = {
__proto__: null,
Glob,
glob,
}; |
||
| function lazyMinimatch() { | ||
| minimatch ??= require('internal/deps/minimatch/index'); | ||
| return minimatch; | ||
| } | ||
|
|
||
| function glob(path, pattern, windows) { | ||
| return lazyMinimatch().minimatch(path, pattern, { | ||
| __proto__: null, | ||
| nocase: isMacOS || isWindows, | ||
| windowsPathsNoEscape: true, | ||
| nonegate: true, | ||
| nocomment: true, | ||
| optimizationLevel: 2, | ||
| platform: windows ? 'win32' : 'posix', | ||
| nocaseMagicOnly: true, | ||
| }); | ||
| } | ||
|
|
||
| class CoverageLine { | ||
| constructor(line, startOffset, src, length = src?.length) { | ||
| const newlineLength = src == null ? 0 : | ||
|
|
@@ -464,19 +483,24 @@ class TestCoverage { | |
| coverageExcludeGlobs: excludeGlobs, | ||
| coverageIncludeGlobs: includeGlobs, | ||
| } = this.options; | ||
|
|
||
| // This check filters out files that match the exclude globs. | ||
| if (excludeGlobs?.length > 0) { | ||
| for (let i = 0; i < excludeGlobs.length; ++i) { | ||
| if (matchesGlob(relativePath, excludeGlobs[i]) || | ||
| matchesGlob(absolutePath, excludeGlobs[i])) return true; | ||
| if ( | ||
| glob(relativePath, excludeGlobs[i]) || | ||
| glob(absolutePath, excludeGlobs[i]) | ||
| ) return true; | ||
| } | ||
| } | ||
|
|
||
| // This check filters out files that do not match the include globs. | ||
| if (includeGlobs?.length > 0) { | ||
| for (let i = 0; i < includeGlobs.length; ++i) { | ||
| if (matchesGlob(relativePath, includeGlobs[i]) || | ||
| matchesGlob(absolutePath, includeGlobs[i])) return false; | ||
| if ( | ||
| glob(relativePath, includeGlobs[i]) || | ||
| glob(absolutePath, includeGlobs[i]) | ||
| ) return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.