Skip to content

Commit

Permalink
Release 0.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jan 21, 2012
1 parent 4c1c1bd commit 52f9dda
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 30 deletions.
7 changes: 7 additions & 0 deletions History.md
@@ -1,4 +1,11 @@

0.10.2 / 2012-01-21
==================

* Fixed suite count in reporter stats. Closes #222
* Fixed `done()` after timeout error reporting [Phil Sung]
* Changed the 0-based errors to 1

0.10.1 / 2012-01-17
==================

Expand Down
2 changes: 1 addition & 1 deletion lib/mocha.js
Expand Up @@ -9,7 +9,7 @@
* Library version.
*/

exports.version = '0.10.1';
exports.version = '0.11.0';

exports.utils = require('./utils');
exports.interfaces = require('./interfaces');
Expand Down
4 changes: 4 additions & 0 deletions mocha.css
Expand Up @@ -40,6 +40,10 @@ body {
color: #888;
}

#mocha .test.pending:hover h2::after {
content: '(pending)';
}

#mocha .test.pass::before {
content: '✓';
font-size: 12px;
Expand Down
70 changes: 42 additions & 28 deletions mocha.js
Expand Up @@ -789,7 +789,7 @@ require.register("mocha.js", function(module, exports, require){
* Library version.
*/

exports.version = '0.10.1';
exports.version = '0.11.0';

exports.utils = require('./utils');
exports.interfaces = require('./interfaces');
Expand Down Expand Up @@ -942,7 +942,7 @@ exports.list = function(failures){
stack = stack.slice(index + 1)
.replace(/^/gm, ' ');

console.error(fmt, i, test.fullTitle(), msg, stack);
console.error(fmt, (i + 1), test.fullTitle(), msg, stack);
});
};

Expand Down Expand Up @@ -972,7 +972,7 @@ function Base(runner) {

runner.on('suite', function(suite){
stats.suites = stats.suites || 0;
stats.suites++;
suite.root || stats.suites++;
});

runner.on('test end', function(test){
Expand Down Expand Up @@ -1298,9 +1298,9 @@ function HTML(runner) {

// toggle code
el.find('h2').toggle(function(){
pre.slideDown('fast');
pre && pre.slideDown('fast');
}, function(){
pre.slideUp('fast');
pre && pre.slideUp('fast');
});

// code
Expand Down Expand Up @@ -1654,7 +1654,7 @@ function List(runner) {

runner.on('fail', function(test, err){
cursor.CR();
console.log(color('fail', ' %d) %s'), n++, test.fullTitle());
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
});

runner.on('end', self.epilogue.bind(self));
Expand Down Expand Up @@ -2115,6 +2115,7 @@ function Runnable(title, fn) {
this.async = fn && fn.length;
this.sync = ! this.async;
this._timeout = 2000;
this.timedOut = false;
this.context = this;
}

Expand Down Expand Up @@ -2178,6 +2179,7 @@ Runnable.prototype.resetTimeout = function(){
if (ms) {
this.timer = setTimeout(function(){
self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
self.timedOut = true;
}, ms);
}
};
Expand All @@ -2202,6 +2204,7 @@ Runnable.prototype.run = function(fn){
if (ms) {
this.timer = setTimeout(function(){
done(new Error('timeout of ' + ms + 'ms exceeded'));
self.timedOut = true;
}, ms);
}
}
Expand All @@ -2215,6 +2218,7 @@ Runnable.prototype.run = function(fn){

// finished
function done(err) {
if (self.timedOut) return;
if (finished) return multiple();
self.clearTimeout();
self.duration = new Date - start;
Expand Down Expand Up @@ -2331,6 +2335,7 @@ Runner.prototype.grep = function(re){
*/

Runner.prototype.globals = function(arr){
if (0 == arguments.length) return this._globals;
debug('globals %j', arr);
utils.forEach(arr, function(arr){
this._globals.push(arr);
Expand Down Expand Up @@ -2388,7 +2393,6 @@ Runner.prototype.fail = function(test, err){
*/

Runner.prototype.failHook = function(hook, err){
++this.failures;
this.fail(hook, err);
this.emit('end');
};
Expand Down Expand Up @@ -2624,6 +2628,32 @@ Runner.prototype.runSuite = function(suite, fn){
});
};

/**
* Handle uncaught exceptions.
*
* @param {Error} err
* @api private
*/

Runner.prototype.uncaught = function(err){
debug('uncaught exception');
var runnable = this.currentRunnable;
if (runnable.failed) return;
runnable.clearTimeout();
err.uncaught = true;
this.fail(runnable, err);

// recover from test
if ('test' == runnable.type) {
this.emit('test end', runnable);
this.hookUp('afterEach', this.next);
return;
}

// bail on hooks
this.emit('end');
};

/**
* Run the root suite and invoke `fn(failures)`
* on completion.
Expand All @@ -2640,9 +2670,9 @@ Runner.prototype.run = function(fn){
debug('start');

// callback
self.on('end', function(){
this.on('end', function(){
debug('end');
process.removeListener('uncaughtException', uncaught);
process.removeListener('uncaughtException', this.uncaught);
fn(self.failures);
});

Expand All @@ -2654,25 +2684,9 @@ Runner.prototype.run = function(fn){
});

// uncaught exception
function uncaught(err){
var runnable = self.currentRunnable;
debug('uncaught exception');
if (runnable.failed) return;
runnable.clearTimeout();
err.uncaught = true;
self.fail(runnable, err);

// recover from test
if ('test' == runnable.type) {
self.emit('test end', runnable);
self.hookUp('afterEach', self.next);
// bail on hooks
} else {
self.emit('end');
}
}

process.on('uncaughtException', uncaught);
process.on('uncaughtException', function(err){
self.uncaught(err);
});

return this;
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "mocha"
, "version": "0.10.1"
, "version": "0.10.2"
, "description": "simple, flexible, fun test framework"
, "keywords": ["test", "bdd", "tdd", "tap"]
, "author": "TJ Holowaychuk <tj@vision-media.ca>"
Expand Down

2 comments on commit 52f9dda

@n1k0
Copy link

@n1k0 n1k0 commented on 52f9dda Jan 22, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just me or there are two different version numbers referenced in this commit — 0.10.2 and 0.11.0?

@tj
Copy link
Contributor Author

@tj tj commented on 52f9dda Jan 22, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup you're right, I was going to bump the minor but realized it was only bugfixes

Please sign in to comment.