Skip to content

Commit

Permalink
Merge pull request #1111 from bnoordhuis/report-errno-global-leaks
Browse files Browse the repository at this point in the history
lib: errno is not a global in node >= v0.9.11

* bnoordhuis/report-errno-global-leaks:
  lib: errno is not a global in node >= v0.9.11
  • Loading branch information
travisjeffery committed Jan 14, 2014
2 parents ffaa38d + e1f2d86 commit 744702b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
14 changes: 13 additions & 1 deletion mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 744702b

Please sign in to comment.