Skip to content

Commit 707d61d

Browse files
authored
Fix RWC Runner to report both .types and .symbols errors (microsoft#10513)
* Correctly append .types or .symbols when calling from rwc runner * Report both errors from generating .types or .symbols * Address PR
1 parent 0b95731 commit 707d61d

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/harness/harness.ts

+19-6
Original file line numberDiff line numberDiff line change
@@ -1370,23 +1370,31 @@ namespace Harness {
13701370

13711371
// Produce baselines. The first gives the types for all expressions.
13721372
// The second gives symbols for all identifiers.
1373-
let e1: Error, e2: Error;
1373+
let typesError: Error, symbolsError: Error;
13741374
try {
13751375
checkBaseLines(/*isSymbolBaseLine*/ false);
13761376
}
13771377
catch (e) {
1378-
e1 = e;
1378+
typesError = e;
13791379
}
13801380

13811381
try {
13821382
checkBaseLines(/*isSymbolBaseLine*/ true);
13831383
}
13841384
catch (e) {
1385-
e2 = e;
1385+
symbolsError = e;
13861386
}
13871387

1388-
if (e1 || e2) {
1389-
throw e1 || e2;
1388+
if (typesError && symbolsError) {
1389+
throw new Error(typesError.message + ts.sys.newLine + symbolsError.message);
1390+
}
1391+
1392+
if (typesError) {
1393+
throw typesError;
1394+
}
1395+
1396+
if (symbolsError) {
1397+
throw symbolsError;
13901398
}
13911399

13921400
return;
@@ -1396,7 +1404,12 @@ namespace Harness {
13961404

13971405
const fullExtension = isSymbolBaseLine ? ".symbols" : ".types";
13981406

1399-
Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, fullExtension), () => fullBaseLine, opts);
1407+
// When calling this function from rwc-runner, the baselinePath will have no extension.
1408+
// As rwc test- file is stored in json which ".json" will get stripped off.
1409+
// When calling this function from compiler-runner, the baselinePath will then has either ".ts" or ".tsx" extension
1410+
const outputFileName = ts.endsWith(baselinePath, ".ts") || ts.endsWith(baselinePath, ".tsx") ?
1411+
baselinePath.replace(/\.tsx?/, fullExtension) : baselinePath.concat(fullExtension);
1412+
Harness.Baseline.runBaseline(outputFileName, () => fullBaseLine, opts);
14001413
}
14011414

14021415
function generateBaseLine(typeWriterResults: ts.Map<TypeWriterResult[]>, isSymbolBaseline: boolean): string {

src/harness/rwcRunner.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ namespace RWC {
223223
});
224224

225225
it("has the expected types", () => {
226-
Harness.Compiler.doTypeAndSymbolBaseline(`${baseName}.types`, compilerResult, inputFiles
226+
// We don't need to pass the extension here because "doTypeAndSymbolBaseline" will append appropriate extension of ".types" or ".symbols"
227+
Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles
227228
.concat(otherFiles)
228229
.filter(file => !!compilerResult.program.getSourceFile(file.unitName))
229230
.filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts);

0 commit comments

Comments
 (0)