Skip to content

Commit 5047d2d

Browse files
Merge pull request #2028 from Microsoft/rwcInvariants
Don't check invariants when running RWC tests. It adds too much running ...
2 parents cb3bc85 + be40cac commit 5047d2d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/harness/harness.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -795,17 +795,19 @@ module Harness {
795795
}
796796
}
797797

798-
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget) {
799-
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ true);
800-
Utils.assertInvariants(result, /*parent:*/ undefined);
798+
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants = true) {
799+
// Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
800+
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants);
801+
if (assertInvariants) {
802+
Utils.assertInvariants(result, /*parent:*/ undefined);
803+
}
801804
return result;
802805
}
803806

804807
export var defaultLibFileName = 'lib.d.ts';
805808
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
806809
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
807810

808-
809811
// Cache these between executions so we don't have to re-parse them for every test
810812
export var fourslashFileName = 'fourslash.ts';
811813
export var fourslashSourceFile: ts.SourceFile;
@@ -926,7 +928,8 @@ module Harness {
926928
settingsCallback?: (settings: ts.CompilerOptions) => void,
927929
options?: ts.CompilerOptions,
928930
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
929-
currentDirectory?: string) {
931+
currentDirectory?: string,
932+
assertInvariants = true) {
930933

931934
options = options || { noResolve: false };
932935
options.target = options.target || ts.ScriptTarget.ES3;
@@ -1074,7 +1077,7 @@ module Harness {
10741077
var register = (file: { unitName: string; content: string; }) => {
10751078
if (file.content !== undefined) {
10761079
var fileName = ts.normalizeSlashes(file.unitName);
1077-
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, options.target);
1080+
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, options.target, assertInvariants);
10781081
}
10791082
};
10801083
inputFiles.forEach(register);

src/harness/rwcRunner.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ module RWC {
9090
/*settingsCallback*/ undefined, opts.options,
9191
// Since all Rwc json file specified current directory in its json file, we need to pass this information to compilerHost
9292
// so that when the host is asked for current directory, it should give the value from json rather than from process
93-
currentDirectory);
93+
currentDirectory,
94+
/*assertInvariants:*/ false);
9495
});
9596

9697
function getHarnessCompilerInputUnit(fileName: string) {

0 commit comments

Comments
 (0)