Skip to content

Commit

Permalink
Release 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 15, 2011
1 parent 01e72be commit 92d7eed
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
10 changes: 10 additions & 0 deletions History.md
@@ -1,4 +1,14 @@

0.4.0 / 2011-12-14
==================

* Added support for test-specific timeouts via `this.timeout(0)`. Closes #134
* Added guillermo's client-side EventEmitter. Closes #132
* Added progress indicator to the HTML reporter
* Fixed slow browser tests. Closes #135
* Fixed "suite" color for light terminals
* Fixed `require()` leak spotted by [guillermo]

0.3.6 / 2011-12-09
==================

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

exports.version = '0.3.6';
exports.version = '0.4.0';

exports.interfaces = require('./interfaces');
exports.reporters = require('./reporters');
Expand Down
53 changes: 47 additions & 6 deletions mocha.js
Expand Up @@ -688,7 +688,7 @@ require.register("mocha.js", function(module, exports, require){
* Library version.
*/

exports.version = '0.3.6';
exports.version = '0.4.0';

exports.interfaces = require('./interfaces');
exports.reporters = require('./reporters');
Expand Down Expand Up @@ -1745,15 +1745,32 @@ function TAP(runner) {
++n;
});

runner.on('pending', function(test){
console.log('ok %d %s # SKIP -', n, title(test));
});

runner.on('pass', function(test){
console.log('ok %d %s', n, test.fullTitle());
console.log('ok %d %s', n, title(test));
});

runner.on('fail', function(test, err){
console.log('not ok %d %s', n, test.fullTitle());
console.log('not ok %d %s', n, title(test));
console.log(err.stack.replace(/^/gm, ' '));
});
}

/**
* Return a TAP-safe title of `test`
*
* @param {Object} test
* @return {String}
* @api private
*/

function title(test) {
return test.fullTitle().replace(/#/g, '');
}

}); // module: reporters/tap.js

require.register("runnable.js", function(module, exports, require){
Expand Down Expand Up @@ -1807,6 +1824,7 @@ Runnable.prototype.timeout = function(ms){
if (0 == arguments.length) return this._timeout;
debug('timeout %d', ms);
this._timeout = ms;
if (this.timer) this.resetTimeout();
return this;
};

Expand All @@ -1832,6 +1850,24 @@ Runnable.prototype.clearTimeout = function(){
clearTimeout(this.timer);
};

/**
* Reset the timeout.
*
* @api private
*/

Runnable.prototype.resetTimeout = function(){
var self = this
, ms = this.timeout();

this.clearTimeout();
if (ms) {
this.timer = setTimeout(function(){
self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
}, ms);
}
};

/**
* Run the test and invoke `fn(err)`.
*
Expand All @@ -1848,9 +1884,11 @@ Runnable.prototype.run = function(fn){

// timeout
if (this.async) {
this.timer = setTimeout(function(){
done(new Error('timeout of ' + ms + 'ms exceeded'));
}, ms);
if (ms) {
this.timer = setTimeout(function(){
done(new Error('timeout of ' + ms + 'ms exceeded'));
}, ms);
}
}

// called multiple times
Expand All @@ -1869,6 +1907,9 @@ Runnable.prototype.run = function(fn){
fn(err);
}

// for .resetTimeout()
this.callback = done;

// async
if (this.async) {
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "mocha"
, "version": "0.3.6"
, "version": "0.4.0"
, "description": "Test framework inspired by JSpec, Expresso, & Qunit"
, "keywords": ["test", "bdd", "tdd", "tap"]
, "bin": { "mocha": "./bin/mocha" }
Expand Down

0 comments on commit 92d7eed

Please sign in to comment.