Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9b23309

Browse filesBrowse files
cjihrigMylesBorins
authored andcommitted
doc,lib,src,test: rename --test-coverage
Add experimental to the name as requested during review. PR-URL: #46017 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
1 parent 6119289 commit 9b23309
Copy full SHA for 9b23309

File tree

Expand file treeCollapse file tree

8 files changed

+42
-35
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

8 files changed

+42
-35
lines changed
Open diff view settings
Collapse file

‎doc/api/cli.md‎

Copy file name to clipboardExpand all lines: doc/api/cli.md
+11-11Lines changed: 11 additions & 11 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,17 @@ added: v19.0.0
434434

435435
Use this flag to enable [ShadowRealm][] support.
436436

437+
### `--experimental-test-coverage`
438+
439+
<!-- YAML
440+
added: REPLACEME
441+
-->
442+
443+
When used in conjunction with the `node:test` module, a code coverage report is
444+
generated as part of the test runner output. If no tests are run, a coverage
445+
report is not generated. See the documentation on
446+
[collecting code coverage from tests][] for more details.
447+
437448
### `--experimental-vm-modules`
438449

439450
<!-- YAML
@@ -1228,17 +1239,6 @@ Starts the Node.js command line test runner. This flag cannot be combined with
12281239
See the documentation on [running tests from the command line][]
12291240
for more details.
12301241

1231-
### `--test-coverage`
1232-
1233-
<!-- YAML
1234-
added: REPLACEME
1235-
-->
1236-
1237-
When used in conjunction with the `node:test` module, a code coverage report is
1238-
generated as part of the test runner output. If no tests are run, a coverage
1239-
report is not generated. See the documentation on
1240-
[collecting code coverage from tests][] for more details.
1241-
12421242
### `--test-name-pattern`
12431243

12441244
<!-- YAML
Collapse file

‎doc/api/test.md‎

Copy file name to clipboardExpand all lines: doc/api/test.md
+11-9Lines changed: 11 additions & 9 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,14 @@ internally.
370370

371371
## Collecting code coverage
372372

373-
When Node.js is started with the [`--test-coverage`][] command-line flag, code
374-
coverage is collected and statistics are reported once all tests have completed.
375-
If the [`NODE_V8_COVERAGE`][] environment variable is used to specify a
376-
code coverage directory, the generated V8 coverage files are written to that
377-
directory. Node.js core modules and files within `node_modules/` directories
378-
are not included in the coverage report. If coverage is enabled, the coverage
379-
report is sent to any [test reporters][] via the `'test:coverage'` event.
373+
When Node.js is started with the [`--experimental-test-coverage`][]
374+
command-line flag, code coverage is collected and statistics are reported once
375+
all tests have completed. If the [`NODE_V8_COVERAGE`][] environment variable is
376+
used to specify a code coverage directory, the generated V8 coverage files are
377+
written to that directory. Node.js core modules and files within
378+
`node_modules/` directories are not included in the coverage report. If
379+
coverage is enabled, the coverage report is sent to any [test reporters][] via
380+
the `'test:coverage'` event.
380381

381382
Coverage can be disabled on a series of lines using the following
382383
comment syntax:
@@ -411,7 +412,8 @@ which will be addressed in a future Node.js release:
411412

412413
* Although coverage data is collected for child processes, this information is
413414
not included in the coverage report. Because the command line test runner uses
414-
child processes to execute test files, it cannot be used with `--test-coverage`.
415+
child processes to execute test files, it cannot be used with
416+
`--experimental-test-coverage`.
415417
* Source maps are not supported.
416418
* Excluding specific files or directories from the coverage report is not
417419
supported.
@@ -1678,8 +1680,8 @@ added:
16781680
aborted.
16791681

16801682
[TAP]: https://testanything.org/
1683+
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
16811684
[`--import`]: cli.md#--importmodule
1682-
[`--test-coverage`]: cli.md#--test-coverage
16831685
[`--test-name-pattern`]: cli.md#--test-name-pattern
16841686
[`--test-only`]: cli.md#--test-only
16851687
[`--test-reporter-destination`]: cli.md#--test-reporter-destination
Collapse file

‎doc/node.1‎

Copy file name to clipboardExpand all lines: doc/node.1
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ Use the specified file as a security policy.
160160
.It Fl -experimental-shadow-realm
161161
Use this flag to enable ShadowRealm support.
162162
.
163+
.It Fl -experimental-test-coverage
164+
Enable code coverage in the test runner.
165+
.
163166
.It Fl -no-experimental-fetch
164167
Disable experimental support for the Fetch API.
165168
.
@@ -391,9 +394,6 @@ Specify the minimum allocation from the OpenSSL secure heap. The default is 2. T
391394
.It Fl -test
392395
Starts the Node.js command line test runner.
393396
.
394-
.It Fl -test-coverage
395-
Enable code coverage in the test runner.
396-
.
397397
.It Fl -test-name-pattern
398398
A regular expression that configures the test runner to only execute tests
399399
whose name matches the provided pattern.
Collapse file

‎lib/internal/process/pre_execution.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/pre_execution.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,10 @@ function setupCodeCoverage() {
301301
// Resolve the coverage directory to an absolute path, and
302302
// overwrite process.env so that the original path gets passed
303303
// to child processes even when they switch cwd. Don't do anything if the
304-
// --test-coverage flag is present, as the test runner will handle coverage.
305-
if (process.env.NODE_V8_COVERAGE && !getOptionValue('--test-coverage')) {
304+
// --experimental-test-coverage flag is present, as the test runner will
305+
// handle coverage.
306+
if (process.env.NODE_V8_COVERAGE &&
307+
!getOptionValue('--experimental-test-coverage')) {
306308
process.env.NODE_V8_COVERAGE =
307309
setupCoverageHooks(process.env.NODE_V8_COVERAGE);
308310
}
Collapse file

‎lib/internal/test_runner/harness.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/harness.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function createProcessEventHandler(eventName, rootTest) {
5757
}
5858

5959
function configureCoverage(rootTest) {
60-
if (!getOptionValue('--test-coverage')) {
60+
if (!getOptionValue('--experimental-test-coverage')) {
6161
return null;
6262
}
6363

Collapse file

‎lib/internal/test_runner/runner.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/runner.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const {
4949
exitCodes: { kGenericUserError },
5050
} = internalBinding('errors');
5151

52-
const kFilterArgs = ['--test', '--test-coverage', '--watch'];
52+
const kFilterArgs = ['--test', '--experimental-test-coverage', '--watch'];
5353
const kFilterArgValues = ['--test-reporter', '--test-reporter-destination'];
5454

5555
// TODO(cjihrig): Replace this with recursive readdir once it lands.
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
143143
if (test_runner_coverage) {
144144
// TODO(cjihrig): This restriction can be removed once multi-process
145145
// code coverage is supported.
146-
errors->push_back("--test-coverage cannot be used with --test");
146+
errors->push_back(
147+
"--experimental-test-coverage cannot be used with --test");
147148
}
148149

149150
if (syntax_check_only) {
@@ -555,7 +556,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
555556
AddOption("--test",
556557
"launch test runner on startup",
557558
&EnvironmentOptions::test_runner);
558-
AddOption("--test-coverage",
559+
AddOption("--experimental-test-coverage",
559560
"enable code coverage in the test runner",
560561
&EnvironmentOptions::test_runner_coverage);
561562
AddOption("--test-name-pattern",
Collapse file

‎test/parallel/test-runner-coverage.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-coverage.js
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,17 @@ function getCoverageFixtureReport() {
3737
return report;
3838
}
3939

40-
test('--test-coverage and --test cannot be combined', () => {
40+
test('--experimental-test-coverage and --test cannot be combined', () => {
4141
// TODO(cjihrig): This test can be removed once multi-process code coverage
4242
// is supported.
43-
const result = spawnSync(process.execPath, ['--test', '--test-coverage']);
43+
const args = ['--test', '--experimental-test-coverage'];
44+
const result = spawnSync(process.execPath, args);
4445

4546
// 9 is the documented exit code for an invalid CLI argument.
4647
assert.strictEqual(result.status, 9);
4748
assert.match(
48-
result.stderr.toString(), /--test-coverage cannot be used with --test/
49+
result.stderr.toString(),
50+
/--experimental-test-coverage cannot be used with --test/
4951
);
5052
});
5153

@@ -55,7 +57,7 @@ test('handles the inspector not being available', (t) => {
5557
}
5658

5759
const fixture = fixtures.path('test-runner', 'coverage.js');
58-
const args = ['--test-coverage', fixture];
60+
const args = ['--experimental-test-coverage', fixture];
5961
const result = spawnSync(process.execPath, args);
6062

6163
assert(!result.stdout.toString().includes('# start of coverage report'));
@@ -70,7 +72,7 @@ test('coverage is reported and dumped to NODE_V8_COVERAGE if present', (t) => {
7072
}
7173

7274
const fixture = fixtures.path('test-runner', 'coverage.js');
73-
const args = ['--test-coverage', fixture];
75+
const args = ['--experimental-test-coverage', fixture];
7476
const options = { env: { ...process.env, NODE_V8_COVERAGE: tmpdir.path } };
7577
const result = spawnSync(process.execPath, args, options);
7678
const report = getCoverageFixtureReport();
@@ -87,7 +89,7 @@ test('coverage is reported without NODE_V8_COVERAGE present', (t) => {
8789
}
8890

8991
const fixture = fixtures.path('test-runner', 'coverage.js');
90-
const args = ['--test-coverage', fixture];
92+
const args = ['--experimental-test-coverage', fixture];
9193
const result = spawnSync(process.execPath, args);
9294
const report = getCoverageFixtureReport();
9395

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.