Skip to content

Commit

Permalink
set max options.timaout accepted value to TIMEOUT_MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jul 17, 2022
1 parent 17ede2d commit 5d2b348
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,8 @@ class Test extends AsyncResource {
}

if (timeout != null && timeout !== Infinity) {
validateNumber(timeout, 'options.timeout', 0);
if (timeout < TIMEOUT_MAX) {
this.timeout = timeout;
}
validateNumber(timeout, 'options.timeout', 0, TIMEOUT_MAX);
this.timeout = timeout;
}

if (testOnlyFlag && !this.only) {
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-runner-option-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const test = require('node:test');
[Symbol(), {}, [], () => {}, 1n, true, '1'].forEach((timeout) => {
assert.throws(() => test({ timeout }), { code: 'ERR_INVALID_ARG_TYPE' });
});
[-1, -Infinity, NaN].forEach((timeout) => {
[-1, -Infinity, NaN, 2 ** 33, Number.MAX_SAFE_INTEGER].forEach((timeout) => {
assert.throws(() => test({ timeout }), { code: 'ERR_OUT_OF_RANGE' });
});
[null, undefined, Infinity, 0, 1, 1.1, 2 ** 33].forEach((timeout) => {
[null, undefined, Infinity, 0, 1, 1.1].forEach((timeout) => {
// Valid values should not throw.
test({ timeout });
});

0 comments on commit 5d2b348

Please sign in to comment.