GeezerVison is showing github.com — test_runner, cli: add --test-timeout flag · nodejs/node@842dc01
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -1743,6 +1743,15 @@ node --test --test-shard=2/3 | 1743 | 1743 | node --test --test-shard=3/3 | 1744 | 1744 | ``` | 1745 | 1745 |
| | 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 | + | 1746 | 1755 | ### `--throw-deprecation` | 1747 | 1756 |
| 1748 | 1757 | <!-- YAML | |
Collapse file Copy file name to clipboardExpand all lines: doc/node.1 +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -438,6 +438,9 @@ option set. | 438 | 438 | . | 439 | 439 | .It Fl -test-shard | 440 | 440 | 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. | 441 | 444 | . | 442 | 445 | .It Fl -throw-deprecation | 443 | 446 | Throw errors for deprecations. | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/main/test_runner.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,11 +60,14 @@ if (shardOption) { | 60 | 60 | }; | 61 | 61 | } | 62 | 62 |
| | 63 | +const timeout = getOptionValue('--test-timeout') || Infinity; | | 64 | + | 63 | 65 | const options = { | 64 | 66 | concurrency, | 65 | 67 | inspectPort, | 66 | 68 | watch: getOptionValue('--watch'), | 67 | 69 | setup: setupTestReporters, | | 70 | + timeout, | 68 | 71 | shard, | 69 | 72 | }; | 70 | 73 | debug('test runner configuration:', options); | |
Collapse file Copy file name to clipboardExpand all lines: src/node_options.cc +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -603,6 +603,9 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | 603 | 603 | AddOption("--test-concurrency", | 604 | 604 | "specify test runner concurrency", | 605 | 605 | &EnvironmentOptions::test_runner_concurrency); | | 606 | + AddOption("--test-timeout", | | 607 | + "specify test runner timeout", | | 608 | + &EnvironmentOptions::test_runner_timeout); | 606 | 609 | AddOption("--experimental-test-coverage", | 607 | 610 | "enable code coverage in the test runner", | 608 | 611 | &EnvironmentOptions::test_runner_coverage); | |
Collapse file Copy file name to clipboardExpand all lines: src/node_options.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -161,6 +161,7 @@ class EnvironmentOptions : public Options { | 161 | 161 | bool has_env_file_string = false; | 162 | 162 | bool test_runner = false; | 163 | 163 | uint64_t test_runner_concurrency = 0; | | 164 | + uint64_t test_runner_timeout = 0; | 164 | 165 | bool test_runner_coverage = false; | 165 | 166 | std::vector<std::string> test_name_pattern; | 166 | 167 | std::vector<std::string> test_reporter; | |
Collapse file Copy file name to clipboard +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | +}); |
|