Skip to content

Commit

Permalink
Allow setting timeout to zero. Closes #117
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Aug 3, 2014
1 parent dd8a489 commit 86d3cd3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/runner.js
Expand Up @@ -325,13 +325,15 @@ internals.protect = function (item, state, callback) {
});
};

var ms = item.options.timeout || state.options.timeout;
var timeoutId = setTimeout(function () {

var error = new Error('Timed out (' + ms + 'ms)');
error.timeout = true;
finish(error, 'timeout');
}, ms);
var ms = item.options.timeout !== undefined ? item.options.timeout : state.options.timeout;
if (ms) {
var timeoutId = setTimeout(function () {

var error = new Error('Timed out (' + ms + 'ms)');
error.timeout = true;
finish(error, 'timeout');
}, ms);
}

var onError = function (err) {

Expand Down
22 changes: 22 additions & 0 deletions test/runner.js
Expand Up @@ -412,4 +412,26 @@ describe('Runner', function () {
done();
});
});

it('disable test timeout', function (done) {

var script = Lab.script();
script.experiment('test', { timeout: 5 }, function () {

script.test('timeout', { timeout: 0 }, function (finished) {

setTimeout(function () {

finished();
}, 10);
});
});

var now = Date.now();
Lab.execute(script, null, null, function (err, notebook) {

expect(Date.now() - now).to.be.above(9);
done();
});
});
});

0 comments on commit 86d3cd3

Please sign in to comment.