diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 534bf85d119..86a68af1145 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -795,9 +795,12 @@ module Harness { } } - export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget) { - var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ true); - Utils.assertInvariants(result, /*parent:*/ undefined); + export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants = true) { + // 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); + if (assertInvariants) { + Utils.assertInvariants(result, /*parent:*/ undefined); + } return result; } @@ -805,7 +808,6 @@ module Harness { 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'; export var fourslashSourceFile: ts.SourceFile; @@ -926,7 +928,8 @@ 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) { + currentDirectory?: string, + assertInvariants = true) { options = options || { noResolve: false }; options.target = options.target || ts.ScriptTarget.ES3; @@ -1074,7 +1077,7 @@ module Harness { var register = (file: { unitName: string; content: string; }) => { if (file.content !== undefined) { var fileName = ts.normalizeSlashes(file.unitName); - filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, options.target); + filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, options.target, assertInvariants); } }; inputFiles.forEach(register); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index b66322f8390..c1c3251cf02 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -90,7 +90,8 @@ module RWC { /*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); + currentDirectory, + /*assertInvariants:*/ false); }); function getHarnessCompilerInputUnit(fileName: string) {