Skip to content

Commit

Permalink
fixed grep. Closes mochajs#372
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 10, 2012
1 parent da04153 commit cfec012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
9 changes: 5 additions & 4 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,15 @@ Runner.prototype.runTests = function(suite, fn){
*/

Runner.prototype.runSuite = function(suite, fn){
var self = this
var total = this.grepTotal(suite)
, self = this
, i = 0;

debug('run suite %s', suite.fullTitle());

if(self.grepTotal(suite)) {
this.emit('suite', this.suite = suite);
}
if (!total) return fn();

this.emit('suite', this.suite = suite);

function next() {
var curr = suite.suites[i++];
Expand Down
14 changes: 6 additions & 8 deletions mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -3052,7 +3052,6 @@ Runner.prototype.grep = function(re){
debug('grep %s', re);
this._grep = re;
this.total = this.grepTotal(this.suite);

return this;
};

Expand All @@ -3070,9 +3069,7 @@ Runner.prototype.grepTotal = function(suite) {
var total = 0;

suite.eachTest(function(test){
if (self._grep.test(test.fullTitle())){
total++;
};
if (self._grep.test(test.fullTitle())) total++;
});

return total;
Expand Down Expand Up @@ -3354,14 +3351,15 @@ Runner.prototype.runTests = function(suite, fn){
*/

Runner.prototype.runSuite = function(suite, fn){
var self = this
var total = this.grepTotal(suite)
, self = this
, i = 0;

debug('run suite %s', suite.fullTitle());

if(self.grepTotal(suite)) {
this.emit('suite', this.suite = suite);
}
if (!total) return fn();

this.emit('suite', this.suite = suite);

function next() {
var curr = suite.suites[i++];
Expand Down

0 comments on commit cfec012

Please sign in to comment.