Skip to content

Commit

Permalink
Prevent tests from locking up browser on slower machines (closes #805).
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Frohs authored and marijnh committed Sep 7, 2012
1 parent dcc976c commit fafa9d2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/driver.js
Expand Up @@ -44,12 +44,16 @@ function runTests(callback) {
}
}
}
var totalTime = 0;
function step(i) {
if (i === tests.length){
running = false;
return callback("done");
}
var test = tests[i], expFail = test.expectedFail;
var test = tests[i]
, expFail = test.expectedFail
, startTime = Date.now()
;
if (debug !== null) {
var debugIndex = debug.indexOf(test.name);
if (debugIndex !== -1) {
Expand Down Expand Up @@ -82,7 +86,13 @@ function runTests(callback) {
else callback("error", test.name, e.toString());
}
if (!quit) { // Run next test
setTimeout(function(){step(i + 1);}, 0);
var delay = 0;
totalTime += (Date.now() - startTime);
if (totalTime > 500){
totalTime = 0;
delay = 50;
}
setTimeout(function(){step(i + 1);}, delay);
} else { // Quit tests
running = false;
return null;
Expand Down

0 comments on commit fafa9d2

Please sign in to comment.