From 180a04805bb4541f8b8da104692c2adca18dd564 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 14 Sep 2010 23:02:48 -0700 Subject: [PATCH] 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. --- src/node.js | 4 ++-- test/simple/test-global-leak.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/simple/test-global-leak.js diff --git a/src/node.js b/src/node.js index 11b391dab8e..24e3925e521 100644 --- a/src/node.js +++ b/src/node.js @@ -534,8 +534,8 @@ var events = module.requireNative('events'); // Signal Handlers (function() { var signalWatchers = {}; - addListener = process.addListener, - removeListener = process.removeListener; + var addListener = process.addListener; + var removeListener = process.removeListener; function isSignal (event) { return event.slice(0, 3) === 'SIG' && process.hasOwnProperty(event); diff --git a/test/simple/test-global-leak.js b/test/simple/test-global-leak.js new file mode 100644 index 00000000000..8406d1efa45 --- /dev/null +++ b/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); + } +}