Skip to content

Commit 24f9ad9

Browse files
committed
test_runner,cli: --test-timeout should be used with --test
1 parent b9289a6 commit 24f9ad9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/node_options.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
142142
errors->push_back("--heapsnapshot-near-heap-limit must not be negative");
143143
}
144144

145+
if (test_runner_timeout > 0 && !test_runner) {
146+
errors->push_back("--test-timeout must be used with --test");
147+
}
148+
145149
if (test_runner) {
146150
if (syntax_check_only) {
147151
errors->push_back("either --test or --check can be used, not both");

test/parallel/test-runner-cli-timeout.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ const { test } = require('node:test');
77
const cwd = fixtures.path('test-runner', 'default-behavior');
88
const env = { ...process.env, 'NODE_DEBUG': 'test_runner' };
99

10+
test('must use --test-timeout with --test', () => {
11+
const args = ['--test-timeout', 10];
12+
const cp = spawnSync(process.execPath, args, { cwd, env });
13+
assert.match(cp.stderr.toString(), /--test-timeout must be used with --test/);
14+
})
15+
1016
test('default timeout -- Infinity', async () => {
1117
const args = ['--test'];
1218
const cp = spawnSync(process.execPath, args, { cwd, env });

0 commit comments

Comments
 (0)