From dc44edfa5f0f69a0702b18b33f6d9c6857cec75d Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Mon, 18 Aug 2014 14:29:55 -0700 Subject: [PATCH] Clean up local state after the describe callback for each compiler test --- src/harness/compilerRunner.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 94e5d09a067..a3357826142 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -39,8 +39,9 @@ class CompilerBaselineRunner extends RunnerBase { public checkTestCodeOutput(fileName: string) { describe('compiler tests for ' + fileName, () => { - // strips the fileName from the path. - var justName = fileName.replace(/^.*[\\\/]/, ''); + // Mocha holds onto the closure environment of the describe callback even after the test is done. + // Everything declared here should be cleared out in the "after" callback. + var justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path. var content = Harness.IO.readFile(fileName); var testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName); @@ -122,6 +123,27 @@ class CompilerBaselineRunner extends RunnerBase { } }); + after(() => { + // Mocha holds onto the closure environment of the describe callback even after the test is done. + // Therefore we have to clean out large objects after the test is done. + justName = undefined; + content = undefined; + testCaseContent = undefined; + units = undefined; + tcSettings = undefined; + lastUnit = undefined; + rootDir = undefined; + result = undefined; + checker = undefined; + options = undefined; + toBeCompiled = undefined; + otherFiles = undefined; + harnessCompiler = undefined; + declToBeCompiled = undefined; + declOtherFiles = undefined; + declResult = undefined; + }); + function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string { return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : ""; }