Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3234dc6

Browse filesBrowse files
avivkellerRafaelGSS
authored andcommitted
test_runner: pass options directly to TestCoverage
PR-URL: #55578 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Raz Luvaton <rluvaton@gmail.com>
1 parent 3477492 commit 3234dc6
Copy full SHA for 3234dc6

File tree

Expand file treeCollapse file tree

1 file changed

+24
-33
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-33
lines changed
Open diff view settings
Collapse file

‎lib/internal/test_runner/coverage.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/coverage.js
+24-33Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,10 @@ class CoverageLine {
5959
class TestCoverage {
6060
constructor(coverageDirectory,
6161
originalCoverageDirectory,
62-
workingDirectory,
63-
excludeGlobs,
64-
includeGlobs,
65-
sourceMaps,
66-
thresholds) {
62+
options) {
6763
this.coverageDirectory = coverageDirectory;
6864
this.originalCoverageDirectory = originalCoverageDirectory;
69-
this.workingDirectory = workingDirectory;
70-
this.excludeGlobs = excludeGlobs;
71-
this.includeGlobs = includeGlobs;
72-
this.sourceMaps = sourceMaps;
73-
this.thresholds = thresholds;
65+
this.options = options;
7466
}
7567

7668
#sourceLines = new SafeMap();
@@ -143,7 +135,7 @@ class TestCoverage {
143135
const coverage = this.getCoverageFromDirectory();
144136
const coverageSummary = {
145137
__proto__: null,
146-
workingDirectory: this.workingDirectory,
138+
workingDirectory: this.options.cwd,
147139
files: [],
148140
totals: {
149141
__proto__: null,
@@ -157,7 +149,12 @@ class TestCoverage {
157149
coveredBranchPercent: 0,
158150
coveredFunctionPercent: 0,
159151
},
160-
thresholds: this.thresholds,
152+
thresholds: {
153+
__proto__: null,
154+
line: this.options.lineCoverage,
155+
branch: this.options.branchCoverage,
156+
function: this.options.functionCoverage,
157+
},
161158
};
162159

163160
if (!coverage) {
@@ -348,7 +345,7 @@ class TestCoverage {
348345
mapCoverageWithSourceMap(coverage) {
349346
const { result } = coverage;
350347
const sourceMapCache = coverage['source-map-cache'];
351-
if (!this.sourceMaps || !sourceMapCache) {
348+
if (!this.options.sourceMaps || !sourceMapCache) {
352349
return result;
353350
}
354351
const newResult = new SafeMap();
@@ -462,21 +459,24 @@ class TestCoverage {
462459
if (!StringPrototypeStartsWith(url, 'file:')) return true;
463460

464461
const absolutePath = fileURLToPath(url);
465-
const relativePath = relative(this.workingDirectory, absolutePath);
466-
462+
const relativePath = relative(this.options.cwd, absolutePath);
463+
const {
464+
coverageExcludeGlobs: excludeGlobs,
465+
coverageIncludeGlobs: includeGlobs,
466+
} = this.options;
467467
// This check filters out files that match the exclude globs.
468-
if (this.excludeGlobs?.length > 0) {
469-
for (let i = 0; i < this.excludeGlobs.length; ++i) {
470-
if (matchesGlob(relativePath, this.excludeGlobs[i]) ||
471-
matchesGlob(absolutePath, this.excludeGlobs[i])) return true;
468+
if (excludeGlobs?.length > 0) {
469+
for (let i = 0; i < excludeGlobs.length; ++i) {
470+
if (matchesGlob(relativePath, excludeGlobs[i]) ||
471+
matchesGlob(absolutePath, excludeGlobs[i])) return true;
472472
}
473473
}
474474

475475
// This check filters out files that do not match the include globs.
476-
if (this.includeGlobs?.length > 0) {
477-
for (let i = 0; i < this.includeGlobs.length; ++i) {
478-
if (matchesGlob(relativePath, this.includeGlobs[i]) ||
479-
matchesGlob(absolutePath, this.includeGlobs[i])) return false;
476+
if (includeGlobs?.length > 0) {
477+
for (let i = 0; i < includeGlobs.length; ++i) {
478+
if (matchesGlob(relativePath, includeGlobs[i]) ||
479+
matchesGlob(absolutePath, includeGlobs[i])) return false;
480480
}
481481
return true;
482482
}
@@ -518,16 +518,7 @@ function setupCoverage(options) {
518518
return new TestCoverage(
519519
coverageDirectory,
520520
originalCoverageDirectory,
521-
options.cwd,
522-
options.coverageExcludeGlobs,
523-
options.coverageIncludeGlobs,
524-
options.sourceMaps,
525-
{
526-
__proto__: null,
527-
line: options.lineCoverage,
528-
branch: options.branchCoverage,
529-
function: options.functionCoverage,
530-
},
521+
options,
531522
);
532523
}
533524

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.