From e51cdb81bdb529a3b71d1f62dd769bc0a5f5a901 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 26 May 2015 10:54:55 +0100 Subject: [PATCH] port leak fixes from smoke-test-sharelatex module --- .../Features/HealthCheck/HealthCheckController.coffee | 9 +++++++++ services/web/test/smoke/coffee/SmokeTests.coffee | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/HealthCheck/HealthCheckController.coffee b/services/web/app/coffee/Features/HealthCheck/HealthCheckController.coffee index 1a82718299..3235b64dbd 100644 --- a/services/web/app/coffee/Features/HealthCheck/HealthCheckController.coffee +++ b/services/web/app/coffee/Features/HealthCheck/HealthCheckController.coffee @@ -15,7 +15,16 @@ module.exports = HealthCheckController = mocha = new Mocha(reporter: Reporter(res), timeout: 10000) mocha.addFile("test/smoke/js/SmokeTests.js") mocha.run () -> + # TODO: combine this with the smoke-test-sharelatex module + # we need to clean up all references to the smokeTest module + # so it can be garbage collected. The only reference should + # be in its parent, when it is loaded by mocha.addFile. path = require.resolve(__dirname + "/../../../../test/smoke/js/SmokeTests.js") + smokeTestModule = require.cache[path] + parent = smokeTestModule.parent + while (idx = parent.children.indexOf(smokeTestModule)) != -1 + parent.children.splice(idx, 1) + # remove the smokeTest from the module cache delete require.cache[path] checkRedis: (req, res, next)-> diff --git a/services/web/test/smoke/coffee/SmokeTests.coffee b/services/web/test/smoke/coffee/SmokeTests.coffee index d14a334b99..714c32289c 100644 --- a/services/web/test/smoke/coffee/SmokeTests.coffee +++ b/services/web/test/smoke/coffee/SmokeTests.coffee @@ -2,7 +2,7 @@ child = require "child_process" fs = require "fs" assert = require("assert") chai = require("chai") -chai.should() +chai.should() unless Object.prototype.should? expect = chai.expect Settings = require "settings-sharelatex" port = Settings.internal?.web?.port or Settings.port or 3000