diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index fd8b248dfe2..85a51b8f2a4 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -55,7 +55,6 @@ class CompilerBaselineRunner extends RunnerBase { let rootDir: string; let result: Harness.Compiler.CompilerResult; - let program: ts.Program; let options: ts.CompilerOptions; // equivalent to the files that will be passed on the command line let toBeCompiled: Harness.Compiler.TestFile[]; @@ -89,12 +88,11 @@ class CompilerBaselineRunner extends RunnerBase { }); } - const output = Harness.Compiler.HarnessCompiler.compileFiles( + const output = Harness.Compiler.compileFiles( toBeCompiled, otherFiles, harnessSettings, /* options */ undefined, /* currentDirectory */ undefined); options = output.options; result = output.result; - program = output.program; }); after(() => { @@ -108,7 +106,6 @@ class CompilerBaselineRunner extends RunnerBase { lastUnit = undefined; rootDir = undefined; result = undefined; - program = undefined; options = undefined; toBeCompiled = undefined; otherFiles = undefined; @@ -181,7 +178,7 @@ class CompilerBaselineRunner extends RunnerBase { } const declFileCompilationResult = - Harness.Compiler.HarnessCompiler.compileDeclarationFiles( + Harness.Compiler.compileDeclarationFiles( toBeCompiled, otherFiles, result, harnessSettings, options, /*currentDirectory*/ undefined); if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { @@ -253,10 +250,10 @@ class CompilerBaselineRunner extends RunnerBase { // These types are equivalent, but depend on what order the compiler observed // certain parts of the program. - const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName)); + const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!result.program.getSourceFile(file.unitName)); - const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); - const pullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ false); + const fullWalker = new TypeWriterWalker(result.program, /*fullTypeCheck*/ true); + const pullWalker = new TypeWriterWalker(result.program, /*fullTypeCheck*/ false); const fullResults: ts.Map = {}; const pullResults: ts.Map = {}; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index ebc58096d6f..f62e1c58412 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2383,10 +2383,9 @@ namespace FourSlash { // here we cache the JS output and reuse it for every test. let fourslashJsOutput: string; { - const fourslashFile: Harness.Compiler.TestFileWithPath = { + const fourslashFile: Harness.Compiler.TestFile = { unitName: Harness.Compiler.fourslashFileName, - content: undefined, - path: ts.toPath(Harness.Compiler.fourslashFileName, Harness.IO.getCurrentDirectory(), Harness.Compiler.getCanonicalFileName) + content: undefined }; const host = Harness.Compiler.createCompilerHost([fourslashFile], (fn, contents) => fourslashJsOutput = contents, @@ -2399,35 +2398,28 @@ namespace FourSlash { program.emit(host.getSourceFile(Harness.Compiler.fourslashFileName, ts.ScriptTarget.ES3)); } - export function runFourSlashTestContent(basePath: string, testType: FourSlashTestType, content: string, fileName: string): TestXmlData { // Parse out the files and their metadata const testData = parseTestData(basePath, content, fileName); currentTestState = new TestState(basePath, testType, testData); - const currentDirectory = Harness.IO.getCurrentDirectory(); - const useCaseSensitiveFileNames = Harness.IO.useCaseSensitiveFileNames(); - const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - let result = ""; - const fourslashFile: Harness.Compiler.TestFileWithPath = { + const fourslashFile: Harness.Compiler.TestFile = { unitName: Harness.Compiler.fourslashFileName, content: undefined, - path: ts.toPath(Harness.Compiler.fourslashFileName, currentDirectory, getCanonicalFileName) }; - const testFile: Harness.Compiler.TestFileWithPath = { + const testFile: Harness.Compiler.TestFile = { unitName: fileName, - content: content, - path: ts.toPath(fileName, currentDirectory, getCanonicalFileName) + content: content }; const host = Harness.Compiler.createCompilerHost( [ fourslashFile, testFile ], (fn, contents) => result = contents, ts.ScriptTarget.Latest, - useCaseSensitiveFileNames, - currentDirectory); + Harness.IO.useCaseSensitiveFileNames(), + Harness.IO.getCurrentDirectory()); const program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); @@ -2444,18 +2436,22 @@ namespace FourSlash { result = fourslashJsOutput + "\r\n" + result; + runCode(result); + + const xmlData = currentTestState.getTestXmlData(); + xmlData.originalName = fileName; + return xmlData; + } + + function runCode(code: string): void { // Compile and execute the test try { - eval(result); + eval(code); } catch (err) { // Debugging: FourSlash.currentTestState.printCurrentFileState(); throw err; } - - const xmlData = currentTestState.getTestXmlData(); - xmlData.originalName = fileName; - return xmlData; } function chompLeadingSpace(content: string) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 9bc36e257ad..e58e6635434 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -767,25 +767,8 @@ namespace Harness { } namespace Harness { - let tcServicesFileName = "typescriptServices.js"; - - export let libFolder: string; - switch (Utils.getExecutionEnvironment()) { - case Utils.ExecutionEnvironment.CScript: - libFolder = "built/local/"; - tcServicesFileName = "built/local/typescriptServices.js"; - break; - case Utils.ExecutionEnvironment.Node: - libFolder = "built/local/"; - tcServicesFileName = "built/local/typescriptServices.js"; - break; - case Utils.ExecutionEnvironment.Browser: - libFolder = "built/local/"; - tcServicesFileName = "built/local/typescriptServices.js"; - break; - default: - throw new Error("Unknown context"); - } + const tcServicesFileName = "built/local/typescriptServices.js"; + export const libFolder = "built/local/"; export let tcServicesFile = IO.readFile(tcServicesFileName); export interface SourceMapEmitterCallback { @@ -827,57 +810,14 @@ namespace Harness { } } - export interface IEmitterIOHost { - writeFile(path: string, contents: string, writeByteOrderMark: boolean): void; - resolvePath(path: string): string; - } - - /** Mimics having multiple files, later concatenated to a single file. */ - export class EmitterIOHost implements IEmitterIOHost { - private fileCollection: any = {}; - - /** create file gets the whole path to create, so this works as expected with the --out parameter */ - public writeFile(s: string, contents: string, writeByteOrderMark: boolean): void { - let writer: ITextWriter; - if (this.fileCollection[s]) { - writer = this.fileCollection[s]; - } - else { - writer = new Harness.Compiler.WriterAggregator(); - this.fileCollection[s] = writer; - } - - writer.Write(contents); - writer.Close(); - } - - public resolvePath(s: string) { return s; } - - public reset() { this.fileCollection = {}; } - - public toArray(): { fileName: string; file: WriterAggregator; }[] { - const result: { fileName: string; file: WriterAggregator; }[] = []; - for (const p in this.fileCollection) { - if (this.fileCollection.hasOwnProperty(p)) { - const current = this.fileCollection[p]; - if (current.lines.length > 0) { - if (p.indexOf(".d.ts") !== -1) { current.lines.unshift(["////[", Path.getFileName(p), "]"].join("")); } - result.push({ fileName: p, file: this.fileCollection[p] }); - } - } - } - return result; - } - } - export function createSourceFileAndAssertInvariants( fileName: string, sourceText: string, languageVersion: ts.ScriptTarget) { - // We'll only assert inletiants outside of light mode. + // We'll only assert invariants outside of light mode. const shouldAssertInvariants = !Harness.lightMode; - // Only set the parent nodes if we're asserting inletiants. We don't need them otherwise. + // Only set the parent nodes if we're asserting invariants. We don't need them otherwise. const result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants); if (shouldAssertInvariants) { @@ -890,12 +830,12 @@ namespace Harness { const carriageReturnLineFeed = "\r\n"; const lineFeed = "\n"; - export let defaultLibFileName = "lib.d.ts"; - export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.core.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest); - export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.core.es6.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest); + export const defaultLibFileName = "lib.d.ts"; + export const defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.core.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest); + export const defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.core.es6.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest); // Cache these between executions so we don't have to re-parse them for every test - export let fourslashFileName = "fourslash.ts"; + export const fourslashFileName = "fourslash.ts"; export let fourslashSourceFile: ts.SourceFile; export function getCanonicalFileName(fileName: string): string { @@ -903,7 +843,7 @@ namespace Harness { } export function createCompilerHost( - inputFiles: TestFileWithPath[], + inputFiles: TestFile[], writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void, scriptTarget: ts.ScriptTarget, useCaseSensitiveFileNames: boolean, @@ -915,16 +855,14 @@ namespace Harness { const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); const fileMap: ts.FileMap = ts.createFileMap(); - - // Register input files - function register(file: TestFileWithPath) { + for (const file of inputFiles) { if (file.content !== undefined) { const fileName = ts.normalizePath(file.unitName); const sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget); - fileMap.set(file.path, sourceFile); + const path = ts.toPath(file.unitName, currentDirectory, getCanonicalFileName); + fileMap.set(path, sourceFile); } - }; - inputFiles.forEach(register); + } function getSourceFile(fn: string, languageVersion: ts.ScriptTarget) { fn = ts.normalizePath(fn); @@ -1031,147 +969,133 @@ namespace Harness { unitName: string; content: string; } - export interface TestFileWithPath extends TestFile { - path: ts.Path; - } export interface CompilationOutput { result: CompilerResult; - program: ts.Program; options: ts.CompilerOptions & HarnessOptions; } - export namespace HarnessCompiler { - export function compileFiles( - inputFiles: TestFile[], - otherFiles: TestFile[], - harnessSettings: TestCaseParser.CompilerSettings, - compilerOptions: ts.CompilerOptions, - // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file - currentDirectory: string): CompilationOutput { + export function compileFiles( + inputFiles: TestFile[], + otherFiles: TestFile[], + harnessSettings: TestCaseParser.CompilerSettings, + compilerOptions: ts.CompilerOptions, + // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file + currentDirectory: string): CompilationOutput { - const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.clone(compilerOptions) : { noResolve: false }; - options.target = options.target || ts.ScriptTarget.ES3; - options.module = options.module || ts.ModuleKind.None; - options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed; - options.noErrorTruncation = true; - options.skipDefaultLibCheck = true; + const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.clone(compilerOptions) : { noResolve: false }; + options.target = options.target || ts.ScriptTarget.ES3; + options.module = options.module || ts.ModuleKind.None; + options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed; + options.noErrorTruncation = true; + options.skipDefaultLibCheck = true; - const newLine = "\r\n"; - currentDirectory = currentDirectory || Harness.IO.getCurrentDirectory(); + const newLine = "\r\n"; + currentDirectory = currentDirectory || Harness.IO.getCurrentDirectory(); - // Parse settings - let useCaseSensitiveFileNames = Harness.IO.useCaseSensitiveFileNames(); - if (harnessSettings) { - setCompilerOptionsFromHarnessSetting(harnessSettings, options); - } - if (options.useCaseSensitiveFileNames !== undefined) { - useCaseSensitiveFileNames = options.useCaseSensitiveFileNames; - } - const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - const inputFilesWithPath = inputFiles.map(f => { - return { unitName: f.unitName, content: f.content, path: ts.toPath(f.unitName, currentDirectory, getCanonicalFileName) }; - }); - const otherFilesWithPath = otherFiles.map(f => { - return { unitName: f.unitName, content: f.content, path: ts.toPath(f.unitName, currentDirectory, getCanonicalFileName) }; - }); - - // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. - // Treat them as library files, so include them in build, but not in baselines. - const includeBuiltFiles: TestFileWithPath[] = []; - if (options.includeBuiltFile) { - const builtFileName = libFolder + options.includeBuiltFile; - const builtFile: TestFileWithPath = { - unitName: builtFileName, - content: normalizeLineEndings(IO.readFile(builtFileName), newLine), - path: ts.toPath(builtFileName, currentDirectory, getCanonicalFileName) - }; - includeBuiltFiles.push(builtFile); - } - - const fileOutputs: GeneratedFile[] = []; - - const programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); - - const compilerHost = createCompilerHost( - inputFilesWithPath.concat(includeBuiltFiles).concat(otherFilesWithPath), - (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), - options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine); - const program = ts.createProgram(programFiles, options, compilerHost); - - const emitResult = program.emit(); - - const errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); - - const result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps); - return { result, program, options }; + // Parse settings + let useCaseSensitiveFileNames = Harness.IO.useCaseSensitiveFileNames(); + if (harnessSettings) { + setCompilerOptionsFromHarnessSetting(harnessSettings, options); + } + if (options.useCaseSensitiveFileNames !== undefined) { + useCaseSensitiveFileNames = options.useCaseSensitiveFileNames; } - export function compileDeclarationFiles(inputFiles: TestFile[], - otherFiles: TestFile[], - result: CompilerResult, - harnessSettings: TestCaseParser.CompilerSettings & HarnessOptions, - options: ts.CompilerOptions, - // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file - currentDirectory: string) { - if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) { - throw new Error("There were no errors and declFiles generated did not match number of js files generated"); + // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. + // Treat them as library files, so include them in build, but not in baselines. + const includeBuiltFiles: TestFile[] = []; + if (options.includeBuiltFile) { + const builtFileName = libFolder + options.includeBuiltFile; + const builtFile: TestFile = { + unitName: builtFileName, + content: normalizeLineEndings(IO.readFile(builtFileName), newLine), + }; + includeBuiltFiles.push(builtFile); + } + + const fileOutputs: GeneratedFile[] = []; + + const programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); + + const compilerHost = createCompilerHost( + inputFiles.concat(includeBuiltFiles).concat(otherFiles), + (fileName, code, writeByteOrderMark) => fileOutputs.push({ fileName, code, writeByteOrderMark }), + options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine); + const program = ts.createProgram(programFiles, options, compilerHost); + + const emitResult = program.emit(); + + const errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + + const result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps); + return { result, options }; + } + + export function compileDeclarationFiles(inputFiles: TestFile[], + otherFiles: TestFile[], + result: CompilerResult, + harnessSettings: TestCaseParser.CompilerSettings & HarnessOptions, + options: ts.CompilerOptions, + // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file + currentDirectory: string) { + if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) { + throw new Error("There were no errors and declFiles generated did not match number of js files generated"); + } + + const declInputFiles: TestFile[] = []; + const declOtherFiles: TestFile[] = []; + + // if the .d.ts is non-empty, confirm it compiles correctly as well + if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) { + ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles)); + ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles)); + const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory); + + return { declInputFiles, declOtherFiles, declResult: output.result }; + } + + function addDtsFile(file: TestFile, dtsFiles: TestFile[]) { + if (isDTS(file.unitName)) { + dtsFiles.push(file); } - - const declInputFiles: TestFile[] = []; - const declOtherFiles: TestFile[] = []; - - // if the .d.ts is non-empty, confirm it compiles correctly as well - if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) { - ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles)); - ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles)); - const output = this.compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory); - - return { declInputFiles, declOtherFiles, declResult: output.result }; - } - - function addDtsFile(file: TestFile, dtsFiles: TestFile[]) { - if (isDTS(file.unitName)) { - dtsFiles.push(file); - } - else if (isTS(file.unitName)) { - const declFile = findResultCodeFile(file.unitName); - if (declFile && !findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) { - dtsFiles.push({ unitName: declFile.fileName, content: declFile.code }); - } - } - - function findResultCodeFile(fileName: string) { - const sourceFile = result.program.getSourceFile(fileName); - assert(sourceFile, "Program has no source file with name '" + fileName + "'"); - // Is this file going to be emitted separately - let sourceFileName: string; - const outFile = options.outFile || options.out; - if (ts.isExternalModule(sourceFile) || !outFile) { - if (options.outDir) { - let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram); - sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); - sourceFileName = ts.combinePaths(options.outDir, sourceFilePath); - } - else { - sourceFileName = sourceFile.fileName; - } - } - else { - // Goes to single --out file - sourceFileName = outFile; - } - - const dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; - - return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); - } - - function findUnit(fileName: string, units: TestFile[]) { - return ts.forEach(units, unit => unit.unitName === fileName ? unit : undefined); + else if (isTS(file.unitName)) { + const declFile = findResultCodeFile(file.unitName); + if (declFile && !findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) { + dtsFiles.push({ unitName: declFile.fileName, content: declFile.code }); } } } + + function findResultCodeFile(fileName: string) { + const sourceFile = result.program.getSourceFile(fileName); + assert(sourceFile, "Program has no source file with name '" + fileName + "'"); + // Is this file going to be emitted separately + let sourceFileName: string; + const outFile = options.outFile || options.out; + if (ts.isExternalModule(sourceFile) || !outFile) { + if (options.outDir) { + let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram); + sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); + sourceFileName = ts.combinePaths(options.outDir, sourceFilePath); + } + else { + sourceFileName = sourceFile.fileName; + } + } + else { + // Goes to single --out file + sourceFileName = outFile; + } + + const dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; + + return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); + } + + function findUnit(fileName: string, units: TestFile[]) { + return ts.forEach(units, unit => unit.unitName === fileName ? unit : undefined); + } } function normalizeLineEndings(text: string, lineEnding: string): string { @@ -1388,7 +1312,7 @@ namespace Harness { constructor(fileResults: GeneratedFile[], errors: ts.Diagnostic[], public program: ts.Program, public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[]) { - fileResults.forEach(emittedFile => { + for (const emittedFile of fileResults) { if (isDTS(emittedFile.fileName)) { // .d.ts file, add to declFiles emit this.declFilesCode.push(emittedFile); @@ -1403,7 +1327,7 @@ namespace Harness { else { throw new Error("Unrecognized file extension for file " + emittedFile.fileName); } - }); + } this.errors = errors; } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 0c267c38f14..3c7814df562 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -7,7 +7,7 @@ namespace Harness.LanguageService { export class ScriptInfo { public version: number = 1; public editRanges: { length: number; textChangeRange: ts.TextChangeRange; }[] = []; - public lineMap: number[] = undefined; + private lineMap: number[] = undefined; constructor(public fileName: string, public content: string) { this.setContent(content); @@ -15,7 +15,11 @@ namespace Harness.LanguageService { private setContent(content: string): void { this.content = content; - this.lineMap = ts.computeLineStarts(content); + this.lineMap = undefined; + } + + public getLineMap(): number[] { + return this.lineMap || (this.lineMap = ts.computeLineStarts(this.content)); } public updateContent(content: string): void { @@ -164,7 +168,7 @@ namespace Harness.LanguageService { const script: ScriptInfo = this.fileNameToScript[fileName]; assert.isNotNull(script); - return ts.computeLineAndCharacterOfPosition(script.lineMap, position); + return ts.computeLineAndCharacterOfPosition(script.getLineMap(), position); } } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index fc1397b294c..ce570a7d6ad 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -126,7 +126,7 @@ namespace RWC { // Emit the results compilerOptions = null; - const output = Harness.Compiler.HarnessCompiler.compileFiles( + const output = Harness.Compiler.compileFiles( inputFiles, otherFiles, /* harnessOptions */ undefined, @@ -202,7 +202,7 @@ namespace RWC { it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { Harness.Baseline.runBaseline("has the expected errors in generated declaration files", baseName + ".dts.errors.txt", () => { - const declFileCompilationResult = Harness.Compiler.HarnessCompiler.compileDeclarationFiles( + const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles( inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory); if (declFileCompilationResult.declResult.errors.length === 0) { diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index 859f10dc4cc..262145b4764 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -32,7 +32,6 @@ class Test262BaselineRunner extends RunnerBase { filename: string; compilerResult: Harness.Compiler.CompilerResult; inputFiles: Harness.Compiler.TestFile[]; - program: ts.Program; }; before(() => { @@ -50,10 +49,9 @@ class Test262BaselineRunner extends RunnerBase { filename: testFilename, inputFiles: inputFiles, compilerResult: undefined, - program: undefined, }; - const output = Harness.Compiler.HarnessCompiler.compileFiles( + const output = Harness.Compiler.compileFiles( [Test262BaselineRunner.helperFile].concat(inputFiles), /*otherFiles*/ [], /* harnessOptions */ undefined, @@ -61,7 +59,6 @@ class Test262BaselineRunner extends RunnerBase { /* currentDirectory */ undefined ); testState.compilerResult = output.result; - testState.program = output.program; }); after(() => { @@ -86,14 +83,14 @@ class Test262BaselineRunner extends RunnerBase { }, false, Test262BaselineRunner.baselineOptions); }); - it("satisfies inletiants", () => { - const sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); + it("satisfies invariants", () => { + const sourceFile = testState.compilerResult.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); Utils.assertInvariants(sourceFile, /*parent:*/ undefined); }); it("has the expected AST", () => { Harness.Baseline.runBaseline("has the expected AST", testState.filename + ".AST.txt", () => { - const sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); + const sourceFile = testState.compilerResult.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); return Utils.sourceFileToJSON(sourceFile); }, false, Test262BaselineRunner.baselineOptions); });