Permalink
Browse files

Merge pull request #224 from psung/test-finishing-after-timeout

Improve error reporting when a test finishes after it has timed out.
  • Loading branch information...
2 parents 40e08ee + 589cf09 commit 4c1c1bd8f6fdc2d36d6be9f2f97ea24255974374 @tj tj committed Jan 21, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/runnable.js
View
@@ -26,6 +26,7 @@ function Runnable(title, fn) {
this.async = fn && fn.length;
this.sync = ! this.async;
this._timeout = 2000;
+ this.timedOut = false;
this.context = this;
}
@@ -87,6 +88,7 @@ Runnable.prototype.resetTimeout = function(){
if (ms) {
this.timer = setTimeout(function(){
self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
+ self.timedOut = true;
}, ms);
}
};
@@ -111,6 +113,7 @@ Runnable.prototype.run = function(fn){
if (ms) {
this.timer = setTimeout(function(){
done(new Error('timeout of ' + ms + 'ms exceeded'));
+ self.timedOut = true;
}, ms);
}
}
@@ -124,6 +127,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;

0 comments on commit 4c1c1bd

Please sign in to comment.