diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 1adf661226e..2d2c90dcb5e 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1343,7 +1343,7 @@ namespace Harness { export function getErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean) { let outputLines = ""; - const gen = iterateErrorBaseline(inputFiles, diagnostics, pretty); + const gen = iterateErrorBaseline(inputFiles, diagnostics, { pretty }); for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { const [, content] = value; outputLines += content; @@ -1353,7 +1353,7 @@ namespace Harness { export const diagnosticSummaryMarker = "__diagnosticSummary"; export const globalErrorsMarker = "__globalErrors"; - export function *iterateErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, pretty?: boolean): IterableIterator<[string, string, number]> { + export function *iterateErrorBaseline(inputFiles: ReadonlyArray, diagnostics: ReadonlyArray, options?: { pretty?: boolean, caseSensitive?: boolean, currentDirectory?: string }): IterableIterator<[string, string, number]> { diagnostics = ts.sort(diagnostics, ts.compareDiagnostics); let outputLines = ""; // Count up all errors that were found in files other than lib.d.ts so we don't miss any @@ -1391,7 +1391,7 @@ namespace Harness { } } - yield [diagnosticSummaryMarker, utils.removeTestPathPrefixes(minimalDiagnosticsToString(diagnostics, pretty)) + IO.newLine() + IO.newLine(), diagnostics.length]; + yield [diagnosticSummaryMarker, utils.removeTestPathPrefixes(minimalDiagnosticsToString(diagnostics, options && options.pretty)) + IO.newLine() + IO.newLine(), diagnostics.length]; // Report global errors const globalErrors = diagnostics.filter(err => !err.file); @@ -1406,7 +1406,7 @@ namespace Harness { // Filter down to the errors in the file const fileErrors = diagnostics.filter((e): e is ts.DiagnosticWithLocation => { const errFn = e.file; - return !!errFn && utils.removeTestPathPrefixes(errFn.fileName) === utils.removeTestPathPrefixes(inputFile.unitName); + return !!errFn && ts.comparePaths(utils.removeTestPathPrefixes(errFn.fileName), utils.removeTestPathPrefixes(inputFile.unitName), options && options.currentDirectory || "", !(options && options.caseSensitive)) === ts.Comparison.EqualTo; }); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 72a372036cc..e86a8d01f70 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -35,6 +35,7 @@ namespace RWC { const baseName = ts.getBaseFileName(jsonPath); let currentDirectory: string; let useCustomLibraryFile: boolean; + let caseSensitive: boolean; after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -47,7 +48,8 @@ namespace RWC { // useCustomLibraryFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts // or to use lib.d.ts inside the json object. If the flag is true, use the lib.d.ts inside json file // otherwise use the lib.d.ts from built/local - useCustomLibraryFile = undefined!; + useCustomLibraryFile = false; + caseSensitive = false; }); it("can compile", function(this: Mocha.ITestCallbackContext) { @@ -93,7 +95,7 @@ namespace RWC { if (!uniqueNames.has(normalized)) { uniqueNames.set(normalized, true); // Load the file - inputFiles.push(getHarnessCompilerInputUnit(normalized)); + inputFiles.push(getHarnessCompilerInputUnit(fileName)); } } @@ -102,7 +104,7 @@ namespace RWC { const unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path)!); if (!uniqueNames.has(unitName) && !Harness.isDefaultLibraryFile(fileRead.path)) { uniqueNames.set(unitName, true); - otherFiles.push(getHarnessCompilerInputUnit(unitName)); + otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } else if (!opts.options.noLib && Harness.isDefaultLibraryFile(fileRead.path) && !uniqueNames.has(unitName) && useCustomLibraryFile) { // If useCustomLibraryFile is true, we will use lib.d.ts from json object @@ -111,7 +113,7 @@ namespace RWC { // lib.d.ts inside json file. However, some RWC cases will still use // their own version of lib.d.ts because they have customized lib.d.ts uniqueNames.set(unitName, true); - inputFiles.push(getHarnessCompilerInputUnit(unitName)); + inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); } } }); @@ -122,11 +124,12 @@ namespace RWC { opts.options.noLib = true; } + caseSensitive = ioLog.useCaseSensitiveFileNames || false; // Emit the results compilerResult = Harness.Compiler.compileFiles( inputFiles, otherFiles, - { useCaseSensitiveFileNames: "" + (ioLog.useCaseSensitiveFileNames || false) }, + { useCaseSensitiveFileNames: "" + caseSensitive }, opts.options, // Since each RWC json file specifies its current directory in its json file, we need // to pass this information in explicitly instead of acquiring it from the process. @@ -182,7 +185,7 @@ namespace RWC { // Do not include the library in the baselines to avoid noise const baselineFiles = tsconfigFiles.concat(inputFiles, otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName)); const errors = compilerResult.diagnostics.filter(e => !e.file || !Harness.isDefaultLibraryFile(e.file.fileName)); - return Harness.Compiler.iterateErrorBaseline(baselineFiles, errors); + return Harness.Compiler.iterateErrorBaseline(baselineFiles, errors, { caseSensitive, currentDirectory }); }, baselineOpts); }); @@ -202,7 +205,7 @@ namespace RWC { compilerResult = undefined!; const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles(declContext)!; - return Harness.Compiler.iterateErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.diagnostics); + return Harness.Compiler.iterateErrorBaseline(tsconfigFiles.concat(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.diagnostics, { caseSensitive, currentDirectory }); }, baselineOpts); } });