Skip to content

Commit 3234dc6

Browse files
avivkellerRafaelGSS
authored andcommitted
test_runner: pass options directly to TestCoverage
PR-URL: #55578 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Raz Luvaton <[email protected]>
1 parent 3477492 commit 3234dc6

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

‎lib/internal/test_runner/coverage.js‎

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,10 @@ class CoverageLine{
5959
classTestCoverage{
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 =newSafeMap();
@@ -143,7 +135,7 @@ class TestCoverage{
143135
constcoverage=this.getCoverageFromDirectory();
144136
constcoverageSummary={
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
constsourceMapCache=coverage['source-map-cache'];
351-
if(!this.sourceMaps||!sourceMapCache){
348+
if(!this.options.sourceMaps||!sourceMapCache){
352349
returnresult;
353350
}
354351
constnewResult=newSafeMap();
@@ -462,21 +459,24 @@ class TestCoverage{
462459
if(!StringPrototypeStartsWith(url,'file:'))returntrue;
463460

464461
constabsolutePath=fileURLToPath(url);
465-
constrelativePath=relative(this.workingDirectory,absolutePath);
466-
462+
constrelativePath=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(leti=0;i<this.excludeGlobs.length;++i){
470-
if(matchesGlob(relativePath,this.excludeGlobs[i])||
471-
matchesGlob(absolutePath,this.excludeGlobs[i]))returntrue;
468+
if(excludeGlobs?.length>0){
469+
for(leti=0;i<excludeGlobs.length;++i){
470+
if(matchesGlob(relativePath,excludeGlobs[i])||
471+
matchesGlob(absolutePath,excludeGlobs[i]))returntrue;
472472
}
473473
}
474474

475475
// This check filters out files that do not match the include globs.
476-
if(this.includeGlobs?.length>0){
477-
for(leti=0;i<this.includeGlobs.length;++i){
478-
if(matchesGlob(relativePath,this.includeGlobs[i])||
479-
matchesGlob(absolutePath,this.includeGlobs[i]))returnfalse;
476+
if(includeGlobs?.length>0){
477+
for(leti=0;i<includeGlobs.length;++i){
478+
if(matchesGlob(relativePath,includeGlobs[i])||
479+
matchesGlob(absolutePath,includeGlobs[i]))returnfalse;
480480
}
481481
returntrue;
482482
}
@@ -518,16 +518,7 @@ function setupCoverage(options){
518518
returnnewTestCoverage(
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)