diff --git a/bin/_mocha b/bin/_mocha old mode 100644 new mode 100755 diff --git a/lib/runner.js b/lib/runner.js index 09ed198313..58f20a90a2 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -58,19 +58,7 @@ function Runner(suite) { this.on('test end', function(test){ self.checkGlobals(test); }); this.on('hook end', function(hook){ self.checkGlobals(hook); }); this.grep(/.*/); - var extraGlobals = []; - if (typeof(process) === 'object' && - typeof(process.versions) === 'object' && - typeof(process.versions.node) === 'string') { - var nodeVersion = process.versions.node.split('.').reduce(function(a, v) { - return a << 8 | v; - }); - // 'errno' was renamed to process._errno in v0.9.11. - if (nodeVersion < 0x00090B) { - extraGlobals.push('errno'); - } - } - this.globals(this.globalProps().concat(extraGlobals)); + this.globals(this.globalProps().concat(extraGlobals())); } /** @@ -650,3 +638,28 @@ function filterLeaks(ok, globals) { return matched.length == 0 && (!global.navigator || 'onerror' !== key); }); } + +/** + * Array of globals dependent on the environment. + * + * @return {Array} + * @api private + */ + + function extraGlobals() { + if (typeof(process) === 'object' && + typeof(process.version) === 'string') { + + var nodeVersion = process.version.split('.').reduce(function(a, v) { + return a << 8 | v; + }); + + // 'errno' was renamed to process._errno in v0.9.11. + + if (nodeVersion < 0x00090B) { + return ['errno']; + } + } + + return []; + } diff --git a/mocha.js b/mocha.js index 78947c6269..c8c9b9ffdf 100644 --- a/mocha.js +++ b/mocha.js @@ -4404,19 +4404,8 @@ function Runner(suite) { this.on('test end', function(test){ self.checkGlobals(test); }); this.on('hook end', function(hook){ self.checkGlobals(hook); }); this.grep(/.*/); - var extraGlobals = []; - if (typeof(process) === 'object' && - typeof(process.versions) === 'object' && - typeof(process.versions.node) === 'string') { - var nodeVersion = process.versions.node.split('.').reduce(function(a, v) { - return a << 8 | v; - }); - // 'errno' was renamed to process._errno in v0.9.11. - if (nodeVersion < 0x00090B) { - extraGlobals.push('errno'); - } - } - this.globals(this.globalProps().concat(extraGlobals)); + console.log(extraGlobals()); + this.globals(this.globalProps().concat(extraGlobals())); } /** @@ -5001,6 +4990,31 @@ function filterLeaks(ok, globals) { }); } +/** + * Array of globals dependent on the environment. + * + * @return {Array} + * @api private + */ + + function extraGlobals() { + if (typeof(process) === 'object' && + typeof(process.version) === 'string') { + + var nodeVersion = process.version.split('.').reduce(function(a, v) { + return a << 8 | v; + }); + + // 'errno' was renamed to process._errno in v0.9.11. + + if (nodeVersion < 0x00090B) { + return ['errno']; + } + } + + return []; + } + }); // module: runner.js require.register("suite.js", function(module, exports, require){