GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner, cli: add --test-timeout flag · nodejs/node@842dc01

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc
    • api
      • cli.md
    • node.1
  • lib/internal/main
    • test_runner.js
  • src
    • node_options.cc
    • node_options.h
  • test/parallel
    • test-runner-cli-timeout.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,15 @@ node --test --test-shard=2/3
17431743
node --test --test-shard=3/3
17441744
```
17451745

1746+
### `--test-timeout`
1747+
1748+
<!-- YAML
1749+
added: REPLACEME
1750+
-->
1751+
1752+
A number of milliseconds the test execution will fail after. If unspecified,
1753+
subtests inherit this value from their parent. The default value is `Infinity`.
1754+
17461755
### `--throw-deprecation`
17471756

17481757
<!-- YAML
Collapse file

‎doc/node.1‎

Copy file name to clipboardExpand all lines: doc/node.1
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ option set.
438438
.
439439
.It Fl -test-shard
440440
Test suite shard to execute in a format of <index>/<total>.
441+
442+
.It Fl -test-timeout
443+
A number of milliseconds the test execution will fail after.
441444
.
442445
.It Fl -throw-deprecation
443446
Throw errors for deprecations.
Collapse file

‎lib/internal/main/test_runner.js‎

Copy file name to clipboardExpand all lines: lib/internal/main/test_runner.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ if (shardOption) {
6060
};
6161
}
6262

63+
const timeout = getOptionValue('--test-timeout') || Infinity;
64+
6365
const options = {
6466
concurrency,
6567
inspectPort,
6668
watch: getOptionValue('--watch'),
6769
setup: setupTestReporters,
70+
timeout,
6871
shard,
6972
};
7073
debug('test runner configuration:', options);
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,9 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
603603
AddOption("--test-concurrency",
604604
"specify test runner concurrency",
605605
&EnvironmentOptions::test_runner_concurrency);
606+
AddOption("--test-timeout",
607+
"specify test runner timeout",
608+
&EnvironmentOptions::test_runner_timeout);
606609
AddOption("--experimental-test-coverage",
607610
"enable code coverage in the test runner",
608611
&EnvironmentOptions::test_runner_coverage);
Collapse file

‎src/node_options.h‎

Copy file name to clipboardExpand all lines: src/node_options.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class EnvironmentOptions : public Options {
161161
bool has_env_file_string = false;
162162
bool test_runner = false;
163163
uint64_t test_runner_concurrency = 0;
164+
uint64_t test_runner_timeout = 0;
164165
bool test_runner_coverage = false;
165166
std::vector<std::string> test_name_pattern;
166167
std::vector<std::string> test_reporter;
Collapse file

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

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
require('../common');
3+
const fixtures = require('../common/fixtures');
4+
const assert = require('node:assert');
5+
const { spawnSync } = require('node:child_process');
6+
const { test } = require('node:test');
7+
const cwd = fixtures.path('test-runner', 'default-behavior');
8+
const env = { ...process.env, 'NODE_DEBUG': 'test_runner' };
9+
10+
test('default timeout -- Infinity', async () => {
11+
const args = ['--test'];
12+
const cp = spawnSync(process.execPath, args, { cwd, env });
13+
assert.match(cp.stderr.toString(), /timeout: Infinity,/);
14+
});
15+
16+
test('timeout of 10ms', async () => {
17+
const args = ['--test', '--test-timeout', 10];
18+
const cp = spawnSync(process.execPath, args, { cwd, env });
19+
assert.match(cp.stderr.toString(), /timeout: 10,/);
20+
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.