Skip to content

Commit dc44edf

Browse files
committed
Clean up local state after the describe callback for each compiler test
1 parent f72ceab commit dc44edf

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/harness/compilerRunner.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ class CompilerBaselineRunner extends RunnerBase {
3939

4040
public checkTestCodeOutput(fileName: string) {
4141
describe('compiler tests for ' + fileName, () => {
42-
// strips the fileName from the path.
43-
var justName = fileName.replace(/^.*[\\\/]/, '');
42+
// Mocha holds onto the closure environment of the describe callback even after the test is done.
43+
// Everything declared here should be cleared out in the "after" callback.
44+
var justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path.
4445
var content = Harness.IO.readFile(fileName);
4546
var testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName);
4647

@@ -122,6 +123,27 @@ class CompilerBaselineRunner extends RunnerBase {
122123
}
123124
});
124125

126+
after(() => {
127+
// Mocha holds onto the closure environment of the describe callback even after the test is done.
128+
// Therefore we have to clean out large objects after the test is done.
129+
justName = undefined;
130+
content = undefined;
131+
testCaseContent = undefined;
132+
units = undefined;
133+
tcSettings = undefined;
134+
lastUnit = undefined;
135+
rootDir = undefined;
136+
result = undefined;
137+
checker = undefined;
138+
options = undefined;
139+
toBeCompiled = undefined;
140+
otherFiles = undefined;
141+
harnessCompiler = undefined;
142+
declToBeCompiled = undefined;
143+
declOtherFiles = undefined;
144+
declResult = undefined;
145+
});
146+
125147
function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string {
126148
return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "";
127149
}

0 commit comments

Comments
 (0)