Merge pull request #184 from sharelatex/fix-leak-in-smoke-tests

port leak fixes from smoke-test-sharelatex module
This commit is contained in:
Henry Oswald 2015-05-26 11:07:51 +01:00
commit a715d60e1c
2 changed files with 10 additions and 1 deletions

View file

@ -15,7 +15,16 @@ module.exports = HealthCheckController =
mocha = new Mocha(reporter: Reporter(res), timeout: 10000) mocha = new Mocha(reporter: Reporter(res), timeout: 10000)
mocha.addFile("test/smoke/js/SmokeTests.js") mocha.addFile("test/smoke/js/SmokeTests.js")
mocha.run () -> 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") 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] delete require.cache[path]
checkRedis: (req, res, next)-> checkRedis: (req, res, next)->

View file

@ -2,7 +2,7 @@ child = require "child_process"
fs = require "fs" fs = require "fs"
assert = require("assert") assert = require("assert")
chai = require("chai") chai = require("chai")
chai.should() chai.should() unless Object.prototype.should?
expect = chai.expect expect = chai.expect
Settings = require "settings-sharelatex" Settings = require "settings-sharelatex"
port = Settings.internal?.web?.port or Settings.port or 3000 port = Settings.internal?.web?.port or Settings.port or 3000