Skip to content

Commit 97d854e

Browse files
cjihrigaduh95
authored andcommitted
test_runner,cli: mark test isolation as stable
This commit stabilizes test isolation configuration in the test runner. PR-URL: #56298 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
1 parent e4b795e commit 97d854e

14 files changed

+55
-48
lines changed

doc/api/cli.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,20 +1037,6 @@ generated as part of the test runner output. If no tests are run, a coverage
10371037
report is not generated. See the documentation on
10381038
[collecting code coverage from tests][] for more details.
10391039

1040-
### `--experimental-test-isolation=mode`
1041-
1042-
<!-- YAML
1043-
added: v22.8.0
1044-
-->
1045-
1046-
> Stability: 1.0 - Early development
1047-
1048-
Configures the type of test isolation used in the test runner. When `mode` is
1049-
`'process'`, each test file is run in a separate child process. When `mode` is
1050-
`'none'`, all test files run in the same process as the test runner. The default
1051-
isolation mode is `'process'`. This flag is ignored if the `--test` flag is not
1052-
present. See the [test runner execution model][] section for more information.
1053-
10541040
### `--experimental-test-module-mocks`
10551041

10561042
<!-- YAML
@@ -2235,8 +2221,8 @@ added:
22352221
-->
22362222

22372223
The maximum number of test files that the test runner CLI will execute
2238-
concurrently. If `--experimental-test-isolation` is set to `'none'`, this flag
2239-
is ignored and concurrency is one. Otherwise, concurrency defaults to
2224+
concurrently. If `--test-isolation` is set to `'none'`, this flag is ignored and
2225+
concurrency is one. Otherwise, concurrency defaults to
22402226
`os.availableParallelism() - 1`.
22412227

22422228
### `--test-coverage-branches=threshold`
@@ -2320,6 +2306,23 @@ added:
23202306
Configures the test runner to exit the process once all known tests have
23212307
finished executing even if the event loop would otherwise remain active.
23222308

2309+
### `--test-isolation=mode`
2310+
2311+
<!-- YAML
2312+
added: v22.8.0
2313+
changes:
2314+
- version: REPLACEME
2315+
pr-url: https://github.com/nodejs/node/pull/56298
2316+
description: This flag was renamed from `--experimental-test-isolation` to
2317+
`--test-isolation`.
2318+
-->
2319+
2320+
Configures the type of test isolation used in the test runner. When `mode` is
2321+
`'process'`, each test file is run in a separate child process. When `mode` is
2322+
`'none'`, all test files run in the same process as the test runner. The default
2323+
isolation mode is `'process'`. This flag is ignored if the `--test` flag is not
2324+
present. See the [test runner execution model][] section for more information.
2325+
23232326
### `--test-name-pattern`
23242327

23252328
<!-- YAML
@@ -3056,6 +3059,7 @@ one is included in the list below.
30563059
* `--experimental-shadow-realm`
30573060
* `--experimental-specifier-resolution`
30583061
* `--experimental-strip-types`
3062+
* `--experimental-test-isolation`
30593063
* `--experimental-top-level-await`
30603064
* `--experimental-transform-types`
30613065
* `--experimental-vm-modules`
@@ -3125,6 +3129,7 @@ one is included in the list below.
31253129
* `--test-coverage-functions`
31263130
* `--test-coverage-include`
31273131
* `--test-coverage-lines`
3132+
* `--test-isolation`
31283133
* `--test-name-pattern`
31293134
* `--test-only`
31303135
* `--test-reporter-destination`

doc/node.1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ Use this flag to enable ShadowRealm support.
180180
.It Fl -experimental-test-coverage
181181
Enable code coverage in the test runner.
182182
.
183-
.It Fl -experimental-test-isolation Ns = Ns Ar mode
184-
Configures the type of test isolation used in the test runner.
185-
.
186183
.It Fl -experimental-test-module-mocks
187184
Enable module mocking in the test runner.
188185
.
@@ -455,6 +452,9 @@ Require a minimum threshold for line coverage (0 - 100).
455452
Configures the test runner to exit the process once all known tests have
456453
finished executing even if the event loop would otherwise remain active.
457454
.
455+
.It Fl -test-isolation Ns = Ns Ar mode
456+
Configures the type of test isolation used in the test runner.
457+
.
458458
.It Fl -test-name-pattern
459459
A regular expression that configures the test runner to only execute tests
460460
whose name matches the provided pattern.

lib/internal/test_runner/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function parseCommandLine() {
241241
}
242242

243243
if (isTestRunner) {
244-
isolation = getOptionValue('--experimental-test-isolation');
244+
isolation = getOptionValue('--test-isolation');
245245
timeout = getOptionValue('--test-timeout') || Infinity;
246246

247247
if (isolation === 'none') {

src/node_options.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors,
145145
debug_options_.allow_attaching_debugger = true;
146146
} else {
147147
if (test_isolation != "process") {
148-
errors->push_back("invalid value for --experimental-test-isolation");
148+
errors->push_back("invalid value for --test-isolation");
149149
}
150150

151151
#ifndef ALLOW_ATTACHING_DEBUGGER_IN_TEST_RUNNER
@@ -683,10 +683,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
683683
"the line coverage minimum threshold",
684684
&EnvironmentOptions::test_coverage_lines,
685685
kAllowedInEnvvar);
686-
687-
AddOption("--experimental-test-isolation",
686+
AddOption("--test-isolation",
688687
"configures the type of test isolation used in the test runner",
689-
&EnvironmentOptions::test_isolation);
688+
&EnvironmentOptions::test_isolation,
689+
kAllowedInEnvvar);
690+
// TODO(cjihrig): Remove this alias in a semver major.
691+
AddAlias("--experimental-test-isolation", "--test-isolation");
690692
AddOption("--experimental-test-module-mocks",
691693
"enable module mocking in the test runner",
692694
&EnvironmentOptions::test_runner_module_mocks);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ test('concurrency of two', async () => {
2626
});
2727

2828
test('isolation=none uses a concurrency of one', async () => {
29-
const args = ['--test', '--experimental-test-isolation=none'];
29+
const args = ['--test', '--test-isolation=none'];
3030
const cp = spawnSync(process.execPath, args, { cwd, env });
3131
assert.match(cp.stderr.toString(), /concurrency: 1,/);
3232
});
3333

3434
test('isolation=none overrides --test-concurrency', async () => {
3535
const args = [
36-
'--test', '--experimental-test-isolation=none', '--test-concurrency=2',
36+
'--test', '--test-isolation=none', '--test-concurrency=2',
3737
];
3838
const cp = spawnSync(process.execPath, args, { cwd, env });
3939
assert.match(cp.stderr.toString(), /concurrency: 1,/);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test('timeout of 10ms', async () => {
2121

2222
test('isolation=none uses the --test-timeout flag', async () => {
2323
const args = [
24-
'--test', '--experimental-test-isolation=none', '--test-timeout=10',
24+
'--test', '--test-isolation=none', '--test-timeout=10',
2525
];
2626
const cp = spawnSync(process.execPath, args, { cwd, env });
2727
assert.match(cp.stderr.toString(), /timeout: 10,/);

test/parallel/test-runner-cli.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ for (const isolation of ['none', 'process']) {
1212
// File not found.
1313
const args = [
1414
'--test',
15-
`--experimental-test-isolation=${isolation}`,
15+
`--test-isolation=${isolation}`,
1616
'a-random-file-that-does-not-exist.js',
1717
];
1818
const child = spawnSync(process.execPath, args);
@@ -27,7 +27,7 @@ for (const isolation of ['none', 'process']) {
2727
// Default behavior. node_modules is ignored. Files that don't match the
2828
// pattern are ignored except in test/ directories.
2929
const args = ['--test', '--test-reporter=tap',
30-
`--experimental-test-isolation=${isolation}`];
30+
`--test-isolation=${isolation}`];
3131
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') });
3232

3333
assert.strictEqual(child.status, 1);
@@ -46,7 +46,7 @@ for (const isolation of ['none', 'process']) {
4646
{
4747
// Should match files with "-test.(c|m)js" suffix.
4848
const args = ['--test', '--test-reporter=tap',
49-
`--experimental-test-isolation=${isolation}`];
49+
`--test-isolation=${isolation}`];
5050
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'matching-patterns') });
5151

5252
assert.strictEqual(child.status, 0);
@@ -64,7 +64,7 @@ for (const isolation of ['none', 'process']) {
6464
for (const type of ['strip', 'transform']) {
6565
// Should match files with "-test.(c|m)(t|j)s" suffix when typescript support is enabled
6666
const args = ['--test', '--test-reporter=tap', '--no-warnings',
67-
`--experimental-${type}-types`, `--experimental-test-isolation=${isolation}`];
67+
`--experimental-${type}-types`, `--test-isolation=${isolation}`];
6868
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'matching-patterns') });
6969

7070
if (!process.config.variables.node_use_amaro) {
@@ -91,7 +91,7 @@ for (const isolation of ['none', 'process']) {
9191
'--require', join(testFixtures, 'protoMutation.js'),
9292
'--test',
9393
'--test-reporter=tap',
94-
`--experimental-test-isolation=${isolation}`,
94+
`--test-isolation=${isolation}`,
9595
];
9696
const child = spawnSync(process.execPath, args, { cwd: join(testFixtures, 'default-behavior') });
9797

@@ -112,7 +112,7 @@ for (const isolation of ['none', 'process']) {
112112
const args = [
113113
'--test',
114114
'--test-reporter=tap',
115-
`--experimental-test-isolation=${isolation}`,
115+
`--test-isolation=${isolation}`,
116116
join(testFixtures, 'index.js'),
117117
];
118118
const child = spawnSync(process.execPath, args, { cwd: testFixtures });
@@ -129,7 +129,7 @@ for (const isolation of ['none', 'process']) {
129129
const args = [
130130
'--test',
131131
'--test-reporter=tap',
132-
`--experimental-test-isolation=${isolation}`,
132+
`--test-isolation=${isolation}`,
133133
join(testFixtures, 'default-behavior/node_modules/*.js'),
134134
];
135135
const child = spawnSync(process.execPath, args);
@@ -143,7 +143,7 @@ for (const isolation of ['none', 'process']) {
143143

144144
{
145145
// The current directory is used by default.
146-
const args = ['--test', `--experimental-test-isolation=${isolation}`];
146+
const args = ['--test', `--test-isolation=${isolation}`];
147147
const options = { cwd: join(testFixtures, 'default-behavior') };
148148
const child = spawnSync(process.execPath, args, options);
149149

@@ -165,7 +165,7 @@ for (const isolation of ['none', 'process']) {
165165
const args = [
166166
'--test',
167167
'--test-reporter=tap',
168-
`--experimental-test-isolation=${isolation}`,
168+
`--test-isolation=${isolation}`,
169169
'test/fixtures/test-runner/default-behavior/index.test.js',
170170
'test/fixtures/test-runner/nested.js',
171171
'test/fixtures/test-runner/invalid-tap.js',

test/parallel/test-runner-coverage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ test.skip('coverage works with isolation=none', skipIfNoInspector, () => {
260260
'--experimental-test-coverage',
261261
'--test-reporter',
262262
'tap',
263-
'--experimental-test-isolation=none',
263+
'--test-isolation=none',
264264
];
265265
const result = spawnSync(process.execPath, args, {
266266
env: { ...process.env, NODE_TEST_TMPDIR: tmpdir.path },

test/parallel/test-runner-extraneous-async-activity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const { spawnSync } = require('child_process');
5252
{
5353
const child = spawnSync(process.execPath, [
5454
'--test',
55-
'--experimental-test-isolation=none',
55+
'--test-isolation=none',
5656
fixtures.path('test-runner', 'async-error-in-test-hook.mjs'),
5757
]);
5858
const stdout = child.stdout.toString();

test/parallel/test-runner-force-exit-failure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ for (const isolation of ['none', 'process']) {
1010
'--test',
1111
'--test-reporter=spec',
1212
'--test-force-exit',
13-
`--experimental-test-isolation=${isolation}`,
13+
`--test-isolation=${isolation}`,
1414
fixture,
1515
];
1616
const r = spawnSync(process.execPath, args);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy