Skip to content

Commit

Permalink
test_runner,cli: --test-timeout should be used with --test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecastelli committed Jul 9, 2024
1 parent b9289a6 commit fe8cc89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
errors->push_back("--heapsnapshot-near-heap-limit must not be negative");
}

if (test_runner_timeout > 0 && !test_runner) {
errors->push_back("--test-timeout must be used with --test");
}

if (test_runner) {
if (syntax_check_only) {
errors->push_back("either --test or --check can be used, not both");
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-runner-cli-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ const { test } = require('node:test');
const cwd = fixtures.path('test-runner', 'default-behavior');
const env = { ...process.env, 'NODE_DEBUG': 'test_runner' };

test('must use --test-timeout with --test', () => {
const args = ['--test-timeout', 10];
const cp = spawnSync(process.execPath, args, { cwd, env });
assert.match(cp.stderr.toString(), /--test-timeout must be used with --test/);
});

test('default timeout -- Infinity', async () => {
const args = ['--test'];
const cp = spawnSync(process.execPath, args, { cwd, env });
Expand Down

0 comments on commit fe8cc89

Please sign in to comment.