diff --git a/Jakefile.js b/Jakefile.js index 9b95744d39..1f88ee3908 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -505,9 +505,9 @@ function cleanTestDirs() { } // used to pass data from jake command line directly to run.js -function writeTestConfigFile(tests, testConfigFile) { +function writeTestConfigFile(tests, light, testConfigFile) { console.log('Running test(s): ' + tests); - var testConfigContents = JSON.stringify({ test: [tests]}); + var testConfigContents = JSON.stringify({ test: [tests], light: light }); fs.writeFileSync('test.config', testConfigContents); } @@ -523,13 +523,14 @@ task("runtests", ["tests", builtLocalDirectory], function() { cleanTestDirs(); host = "mocha" tests = process.env.test || process.env.tests || process.env.t; + var light = process.env.light || false; var testConfigFile = 'test.config'; if(fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); } - if(tests) { - writeTestConfigFile(tests, testConfigFile); + if(tests || light) { + writeTestConfigFile(tests, light, testConfigFile); } if (tests && tests.toLocaleLowerCase() === "rwc") { @@ -572,12 +573,13 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function( port = process.env.port || process.env.p || '8888'; browser = process.env.browser || process.env.b || "IE"; tests = process.env.test || process.env.tests || process.env.t; + var light = process.env.light || false; var testConfigFile = 'test.config'; if(fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); } - if(tests) { - writeTestConfigFile(tests, testConfigFile); + if(tests || light) { + writeTestConfigFile(tests, light, testConfigFile); } tests = tests ? tests : ''; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 08a6576e5c..7bbfd36bf4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11609,7 +11609,9 @@ namespace ts { function checkSourceFile(node: SourceFile) { let start = new Date().getTime(); + checkSourceFileWorker(node); + checkTime += new Date().getTime() - start; } @@ -11617,6 +11619,8 @@ namespace ts { function checkSourceFileWorker(node: SourceFile) { let links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { + // Check whether the file has declared it is the default lib, + // and whether the user has specifically chosen to avoid checking it. if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) { return; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3478347022..562654c2ed 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -144,21 +144,30 @@ namespace ts { let program: Program; let files: SourceFile[] = []; let diagnostics = createDiagnosticCollection(); - let skipDefaultLib = options.noLib; + let commonSourceDirectory: string; let diagnosticsProducingTypeChecker: TypeChecker; let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; + let skipDefaultLib = options.noLib; + let start = new Date().getTime(); host = host || createCompilerHost(options); + let filesByName = createFileMap(fileName => host.getCanonicalFileName(fileName)); forEach(rootNames, name => processRootFile(name, /*isDefaultLib:*/ false)); + + // Do not process the default library if: + // - The '--noLib' flag is used. + // - A 'no-default-lib' reference comment is encountered in + // processing the root files. if (!skipDefaultLib) { processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib:*/ true); } + verifyCompilerOptions(); programTime += new Date().getTime() - start; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8be7c1792a..9c0fd3d0b2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1149,6 +1149,14 @@ namespace ts { moduleName: string; referencedFiles: FileReference[]; + /** + * lib.d.ts should have a reference comment like + * + * /// + * + * If any other file has this comment, it signals not to include lib.d.ts + * because this containing file is intended to act as a default library. + */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; @@ -1860,7 +1868,10 @@ namespace ts { experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; /* @internal */ stripInternal?: boolean; + + // Skip checking lib.d.ts to help speed up tests. /* @internal */ skipDefaultLibCheck?: boolean; + [option: string]: string | number | boolean; } diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index b6997e705b..21e88b9e41 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -1,7 +1,6 @@ /// /// /// -/// const enum CompilerTestType { Conformance, @@ -18,7 +17,7 @@ class CompilerBaselineRunner extends RunnerBase { public options: string; - constructor(public testType?: CompilerTestType) { + constructor(public testType: CompilerTestType) { super(); this.errors = true; this.emit = true; @@ -171,7 +170,6 @@ class CompilerBaselineRunner extends RunnerBase { } }); - it('Correct JS output for ' + fileName, () => { if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) { if (result.files.length === 0 && result.errors.length === 0) { @@ -195,8 +193,6 @@ class CompilerBaselineRunner extends RunnerBase { jsCode += '//// [' + Harness.Path.getFileName(result.files[i].fileName) + ']\r\n'; jsCode += getByteOrderMarkText(result.files[i]); jsCode += result.files[i].code; - // Re-enable this if we want to do another comparison of old vs new compiler baselines - // jsCode += SyntacticCleaner.clean(result.files[i].code); } if (result.declFilesCode.length > 0) { diff --git a/src/harness/exec.ts b/src/harness/exec.ts deleted file mode 100644 index 6ed538b1d4..0000000000 --- a/src/harness/exec.ts +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// Allows for executing a program with command-line arguments and reading the result -interface IExec { - exec: (fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) => void; -} - -class ExecResult { - public stdout = ""; - public stderr = ""; - public exitCode: number; -} - -class WindowsScriptHostExec implements IExec { - public exec(fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) : void { - var result = new ExecResult(); - var shell = new ActiveXObject('WScript.Shell'); - try { - var process = shell.Exec(fileName + ' ' + cmdLineArgs.join(' ')); - } catch(e) { - result.stderr = e.message; - result.exitCode = 1; - handleResult(result); - return; - } - // Wait for it to finish running - while (process.Status != 0) { /* todo: sleep? */ } - - - result.exitCode = process.ExitCode; - if(!process.StdOut.AtEndOfStream) result.stdout = process.StdOut.ReadAll(); - if(!process.StdErr.AtEndOfStream) result.stderr = process.StdErr.ReadAll(); - - handleResult(result); - } -} - -class NodeExec implements IExec { - public exec(fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) : void { - var nodeExec = require('child_process').exec; - - var result = new ExecResult(); - result.exitCode = null; - var cmdLine = fileName + ' ' + cmdLineArgs.join(' '); - var process = nodeExec(cmdLine, function(error: any, stdout: string, stderr: string) { - result.stdout = stdout; - result.stderr = stderr; - result.exitCode = error ? error.code : 0; - handleResult(result); - }); - } -} - -var Exec: IExec = function() : IExec { - var global = Function("return this;").call(null); - if(typeof global.ActiveXObject !== "undefined") { - return new WindowsScriptHostExec(); - } else { - return new NodeExec(); - } -}(); \ No newline at end of file diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8d313c9a1a..bf6e120ec3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -343,7 +343,8 @@ module FourSlash { if (!resolvedResult.isLibFile) { this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.defaultLibSourceFile.text); } - } else { + } + else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles ts.forEachKey(this.inputFiles, fileName => { if (!Harness.isLibraryFile(fileName)) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 82afea4cf4..6a55948815 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -99,7 +99,7 @@ module Utils { } try { - var content = ts.sys.readFile(Harness.userSpecifiedroot + path); + var content = ts.sys.readFile(Harness.userSpecifiedRoot + path); } catch (err) { return undefined; @@ -732,7 +732,8 @@ module Harness { } // Settings - export var userSpecifiedroot = ""; + export let userSpecifiedRoot = ""; + export let lightMode = false; /** Functionality for compiling TypeScript code */ export module Compiler { @@ -809,17 +810,19 @@ module Harness { } export function createSourceFileAndAssertInvariants( - fileName: string, - sourceText: string, - languageVersion: ts.ScriptTarget, - assertInvariants: boolean) { - + fileName: string, + sourceText: string, + languageVersion: ts.ScriptTarget) { + // We'll only assert invariants outside of light mode. + const shouldAssertInvariants = !Harness.lightMode; + // Only set the parent nodes if we're asserting invariants. We don't need them otherwise. - var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants); + var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants); - if (assertInvariants) { + if (shouldAssertInvariants) { Utils.assertInvariants(result, /*parent:*/ undefined); } + return result; } @@ -827,8 +830,8 @@ module Harness { const lineFeed = "\n"; export var defaultLibFileName = 'lib.d.ts'; - export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true); - export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true); + export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); + export var 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 var fourslashFileName = 'fourslash.ts'; @@ -859,7 +862,7 @@ module Harness { function register(file: { unitName: string; content: string; }) { if (file.content !== undefined) { var fileName = ts.normalizePath(file.unitName); - filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget, /*assertInvariants:*/ true); + filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget); } }; inputFiles.forEach(register); @@ -882,7 +885,7 @@ module Harness { } else if (fn === fourslashFileName) { var tsFn = 'tests/cases/fourslash/' + fourslashFileName; - fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget, /*assertInvariants:*/ true); + fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); return fourslashSourceFile; } else { @@ -939,17 +942,19 @@ module Harness { } public emitAll(ioHost?: IEmitterIOHost) { - this.compileFiles(this.inputFiles, [],(result) => { - result.files.forEach(file => { - ioHost.writeFile(file.fileName, file.code, false); - }); - result.declFilesCode.forEach(file => { - ioHost.writeFile(file.fileName, file.code, false); - }); - result.sourceMaps.forEach(file => { - ioHost.writeFile(file.fileName, file.code, false); - }); - },() => { }, this.compileOptions); + this.compileFiles(this.inputFiles, + /*otherFiles*/ [], + /*onComplete*/ result => { + result.files.forEach(writeFile); + result.declFilesCode.forEach(writeFile); + result.sourceMaps.forEach(writeFile); + }, + /*settingsCallback*/ () => { }, + this.compileOptions); + + function writeFile(file: GeneratedFile) { + ioHost.writeFile(file.fileName, file.code, false); + } } public compileFiles(inputFiles: { unitName: string; content: string }[], @@ -958,8 +963,7 @@ module Harness { settingsCallback?: (settings: ts.CompilerOptions) => void, options?: ts.CompilerOptions, // Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file - currentDirectory?: string, - assertInvariants = true) { + currentDirectory?: string) { options = options || { noResolve: false }; options.target = options.target || ts.ScriptTarget.ES3; @@ -979,7 +983,31 @@ module Harness { var includeBuiltFiles: { unitName: string; content: string }[] = []; var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; - this.settings.forEach(setting => { + this.settings.forEach(setCompilerOptionForSetting); + + var fileOutputs: GeneratedFile[] = []; + + var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); + + var compilerHost = createCompilerHost( + inputFiles.concat(includeBuiltFiles).concat(otherFiles), + (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), + options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine); + var program = ts.createProgram(programFiles, options, compilerHost); + + var emitResult = program.emit(); + + var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + this.lastErrors = errors; + + var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); + onComplete(result, program); + + // reset what newline means in case the last test changed it + ts.sys.newLine = newLine; + return options; + + function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) { switch (setting.flag.toLowerCase()) { // "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve" case "module": @@ -1133,7 +1161,7 @@ module Harness { case 'inlinesourcemap': options.inlineSourceMap = setting.value === 'true'; break; - + case 'inlinesources': options.inlineSources = setting.value === 'true'; break; @@ -1141,28 +1169,7 @@ module Harness { default: throw new Error('Unsupported compiler setting ' + setting.flag); } - }); - - var fileOutputs: GeneratedFile[] = []; - - var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); - var compilerHost = createCompilerHost( - inputFiles.concat(includeBuiltFiles).concat(otherFiles), - (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), - options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine); - var program = ts.createProgram(programFiles, options, compilerHost); - - var emitResult = program.emit(); - - var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); - this.lastErrors = errors; - - var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); - onComplete(result, program); - - // reset what newline means in case the last test changed it - ts.sys.newLine = newLine; - return options; + } } public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[], @@ -1363,29 +1370,30 @@ module Harness { ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n'); } - export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) { + export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { // Collect, test, and sort the fileNames - function cleanName(fn: string) { - var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); - return fn.substr(lastSlash + 1).toLowerCase(); - } outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); // Emit them var result = ''; - ts.forEach(outputFiles, outputFile => { + for (let outputFile of outputFiles) { // Some extra spacing if this isn't the first file - if (result.length) result = result + '\r\n\r\n'; + if (result.length) { + result += '\r\n\r\n'; + } // FileName header + content - result = result + '/*====== ' + outputFile.fileName + ' ======*/\r\n'; - if (clean) { - result = result + clean(outputFile.code); - } else { - result = result + outputFile.code; - } - }); + result += '/*====== ' + outputFile.fileName + ' ======*/\r\n'; + + result += outputFile.code; + } + return result; + + function cleanName(fn: string) { + var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); + return fn.substr(lastSlash + 1).toLowerCase(); + } } /** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */ @@ -1487,16 +1495,6 @@ module Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines - // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", - "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", - "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", - "errortruncation", "usecasesensitivefilenames", "preserveconstenums", - "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", - "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", - "inlinesources", "emitdecoratormetadata", "experimentaldecorators", - "skipdefaultlibcheck"]; - function extractCompilerSettings(content: string): CompilerSetting[] { var opts: CompilerSetting[] = []; @@ -1530,10 +1528,8 @@ module Harness { if (testMetaData) { // Comment line, check for global/file @options and record them optionRegex.lastIndex = 0; - var fileNameIndex = fileMetadataNames.indexOf(testMetaData[1].toLowerCase()); - if (fileNameIndex === -1) { - throw new Error('Unrecognized metadata name "' + testMetaData[1] + '". Available file metadata names are: ' + fileMetadataNames.join(', ')); - } else if (fileNameIndex === 0) { + var metaDataName = testMetaData[1].toLowerCase(); + if (metaDataName === "filename") { currentFileOptions[testMetaData[1]] = testMetaData[2]; } else { continue; @@ -1619,9 +1615,9 @@ module Harness { function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) { if (subfolder !== undefined) { - return Harness.userSpecifiedroot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedRoot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName; } else { - return Harness.userSpecifiedroot + baselineFolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedRoot + baselineFolder + '/' + type + '/' + fileName; } } @@ -1730,7 +1726,7 @@ module Harness { } export function getDefaultLibraryFile(): { unitName: string, content: string } { - var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts"; + var libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; return { unitName: libFile, content: IO.readFile(libFile) diff --git a/src/harness/project.ts b/src/harness/project.ts deleted file mode 100644 index d94cbd576d..0000000000 --- a/src/harness/project.ts +++ /dev/null @@ -1,19 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -/// -/// -/// -/// diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index cb454c00e6..324524272e 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -174,7 +174,7 @@ class ProjectRunner extends RunnerBase { else { var text = getSourceFileText(fileName); if (text !== undefined) { - sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion, /*assertInvariants:*/ true); + sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion); } } diff --git a/src/harness/runner.ts b/src/harness/runner.ts index eae4d77bb2..42c2d5667c 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -18,6 +18,7 @@ /// /// /// +/// function runTests(runners: RunnerBase[]) { for (var i = iterations; i > 0; i--) { @@ -39,6 +40,9 @@ var testConfigFile = if (testConfigFile !== '') { var testConfig = JSON.parse(testConfigFile); + if (testConfig.light) { + Harness.lightMode = true; + } if (testConfig.test && testConfig.test.length > 0) { for (let option of testConfig.test) { diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 49ca796448..269e889704 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -12,7 +12,7 @@ class RunnerBase { } public enumerateFiles(folder: string, regex?: RegExp, options?: { recursive: boolean }): string[] { - return Harness.IO.listFiles(Harness.userSpecifiedroot + folder, regex, { recursive: (options ? options.recursive : false) }); + return Harness.IO.listFiles(Harness.userSpecifiedRoot + folder, regex, { recursive: (options ? options.recursive : false) }); } /** Setup the runner's tests so that they are ready to be executed by the harness diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 49a15112e9..43a118b6ae 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -1,6 +1,5 @@ /// /// -/// /// /// @@ -75,7 +74,7 @@ module RWC { }); // Add files to compilation - for(let fileRead of ioLog.filesRead) { + for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath); @@ -107,14 +106,14 @@ module RWC { opts.options.noLib = true; // Emit the results - compilerOptions = harnessCompiler.compileFiles(inputFiles, otherFiles, compileResult => { - compilerResult = compileResult; - }, + compilerOptions = harnessCompiler.compileFiles( + inputFiles, + otherFiles, + newCompilerResults => { compilerResult = newCompilerResults; }, /*settingsCallback*/ undefined, opts.options, - // Since all Rwc json file specified current directory in its json file, we need to pass this information to compilerHost - // so that when the host is asked for current directory, it should give the value from json rather than from process - currentDirectory, - /*assertInvariants:*/ false); + // 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. + currentDirectory); }); function getHarnessCompilerInputUnit(fileName: string) { @@ -132,7 +131,7 @@ module RWC { it('has the expected emitted code', () => { Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => { - return Harness.Compiler.collateOutputs(compilerResult.files, s => SyntacticCleaner.clean(s)); + return Harness.Compiler.collateOutputs(compilerResult.files); }, false, baselineOpts); }); diff --git a/src/harness/syntacticCleaner.ts b/src/harness/syntacticCleaner.ts deleted file mode 100644 index 05b4295124..0000000000 --- a/src/harness/syntacticCleaner.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Use this to get emitter-agnostic baselines - -class SyntacticCleaner { - static clean(sourceFileContents: string) { - return sourceFileContents; - } -} - -/* TODO: Re-implement or maybe delete -class SyntacticCleaner extends TypeScript.SyntaxWalker { - private emit: string[] = []; - - public visitToken(token: TypeScript.ISyntaxToken): void { - this.emit.push(token.text()); - if (token.kind() === TypeScript.SyntaxKind.SemicolonToken) { - this.emit.push('\r\n'); - } else { - this.emit.push(' '); - - } - } - - static clean(sourceFileContents: string): string { - var parsed = TypeScript.Parser.parse('_emitted.ts', TypeScript.SimpleText.fromString(sourceFileContents), TypeScript.LanguageVersion.EcmaScript5, false); - var cleaner = new SyntacticCleaner(); - cleaner.visitSourceUnit(parsed.sourceUnit()); - return cleaner.emit.join(''); - } -} -*/ diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index 0091da5e91..5f8250c5e2 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -1,6 +1,5 @@ /// /// -/// class Test262BaselineRunner extends RunnerBase { private static basePath = 'internal/cases/test262'; @@ -65,7 +64,7 @@ class Test262BaselineRunner extends RunnerBase { it('has the expected emitted code', () => { Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => { var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath); - return Harness.Compiler.collateOutputs(files, s => SyntacticCleaner.clean(s)); + return Harness.Compiler.collateOutputs(files); }, false, Test262BaselineRunner.baselineOptions); }); diff --git a/tests/baselines/reference/parser509698.errors.txt b/tests/baselines/reference/parser509698.errors.txt index 2aaaec18dc..dfc155dd36 100644 --- a/tests/baselines/reference/parser509698.errors.txt +++ b/tests/baselines/reference/parser509698.errors.txt @@ -18,7 +18,6 @@ error TS2318: Cannot find global type 'String'. !!! error TS2318: Cannot find global type 'String'. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ==== ///