diff --git a/lib/runner.js b/lib/runner.js index f2420f2e4e..09ed198313 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -58,7 +58,19 @@ function Runner(suite) { this.on('test end', function(test){ self.checkGlobals(test); }); this.on('hook end', function(hook){ self.checkGlobals(hook); }); this.grep(/.*/); - this.globals(this.globalProps().concat(['errno'])); + 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)); } /** diff --git a/mocha.js b/mocha.js index e4f8e6b202..78947c6269 100644 --- a/mocha.js +++ b/mocha.js @@ -4404,7 +4404,19 @@ function Runner(suite) { this.on('test end', function(test){ self.checkGlobals(test); }); this.on('hook end', function(hook){ self.checkGlobals(hook); }); this.grep(/.*/); - this.globals(this.globalProps().concat(['errno'])); + 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)); } /**