Skip to content

Commit 4587871

Browse files
authored
Fix RWC tests with errors in tsconfig (#52824)
1 parent b579516 commit 4587871

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/harness/harnessIO.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ export namespace Compiler {
567567
diagnostics = ts.sort(diagnostics, ts.compareDiagnostics);
568568
let outputLines = "";
569569
// Count up all errors that were found in files other than lib.d.ts so we don't miss any
570-
let totalErrorsReportedInNonLibraryFiles = 0;
570+
let totalErrorsReportedInNonLibraryNonTsconfigFiles = 0;
571571

572572
let errorsReported = 0;
573573

@@ -609,10 +609,11 @@ export namespace Compiler {
609609
// do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics
610610
// if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers)
611611
// then they will be added twice thus triggering 'total errors' assertion with condition
612-
// 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
612+
// Similarly for tsconfig, which may be in the input files and contain errors.
613+
// 'totalErrorsReportedInNonLibraryNonTsconfigFiles + numLibraryDiagnostics + numTsconfigDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
613614

614-
if (!error.file || !isDefaultLibraryFile(error.file.fileName)) {
615-
totalErrorsReportedInNonLibraryFiles++;
615+
if (!error.file || !isDefaultLibraryFile(error.file.fileName) && !vpath.isTsConfigFile(error.file.fileName)) {
616+
totalErrorsReportedInNonLibraryNonTsconfigFiles++;
616617
}
617618
}
618619

@@ -704,7 +705,7 @@ export namespace Compiler {
704705
// Case-duplicated files on a case-insensitive build will have errors reported in both the dupe and the original
705706
// thanks to the canse-insensitive path comparison on the error file path - We only want to count those errors once
706707
// for the assert below, so we subtract them here.
707-
totalErrorsReportedInNonLibraryFiles -= errorsReported;
708+
totalErrorsReportedInNonLibraryNonTsconfigFiles -= errorsReported;
708709
}
709710
outputLines = "";
710711
errorsReported = 0;
@@ -714,13 +715,17 @@ export namespace Compiler {
714715
return !!diagnostic.file && (isDefaultLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName));
715716
});
716717

718+
const numTsconfigDiagnostics = ts.countWhere(diagnostics, diagnostic => {
719+
return !!diagnostic.file && (vpath.isTsConfigFile(diagnostic.file.fileName));
720+
});
721+
717722
const numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
718723
// Count an error generated from tests262-harness folder.This should only apply for test262
719724
return !!diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0;
720725
});
721726

722727
// Verify we didn't miss any errors in total
723-
assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors");
728+
assert.equal(totalErrorsReportedInNonLibraryNonTsconfigFiles + numLibraryDiagnostics + numTsconfigDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors");
724729
}
725730

726731
export function doErrorBaseline(baselinePath: string, inputFiles: readonly TestFile[], errors: readonly ts.Diagnostic[], pretty?: boolean) {

0 commit comments

Comments
 (0)