Browse Source

Make a list of known globals

And fix missing var!

It would be good to get this script running at the end of every test, so we
know that modules aren't leaking either - but it will require a lot
modification of the tests so that they themselves aren't leaking globals.
v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
feea1330cc
  1. 4
      src/node.js
  2. 32
      test/simple/test-global-leak.js

4
src/node.js

@ -534,8 +534,8 @@ var events = module.requireNative('events');
// Signal Handlers // Signal Handlers
(function() { (function() {
var signalWatchers = {}; var signalWatchers = {};
addListener = process.addListener, var addListener = process.addListener;
removeListener = process.removeListener; var removeListener = process.removeListener;
function isSignal (event) { function isSignal (event) {
return event.slice(0, 3) === 'SIG' && process.hasOwnProperty(event); return event.slice(0, 3) === 'SIG' && process.hasOwnProperty(event);

32
test/simple/test-global-leak.js

@ -0,0 +1,32 @@
var assert = require('assert');
var knownGlobals = [ setTimeout
, setInterval
, clearTimeout
, clearInterval
, console
, Buffer
, process
, global
, __module
, include
, puts
, print
, p
];
for (var x in global) {
var found = false;
for (var y in knownGlobals) {
if (global[x] === knownGlobals[y]) {
found = true;
break;
}
}
if (!found) {
console.error("Unknown global: %s", x);
assert.ok(false);
}
}
Loading…
Cancel
Save