Skip to content

Commit bae14b7

Browse files
authored
test: do not set concurrency on parallelized runs
Our CI already run test files in parallel, having `node:test` spawns child processes concurrently could lead to oversubscribing the CI machine. This commit sets the `concurrency` depending on the presence of `TEST_PARALLEL` in the env, so running the test file individually still spawns child processes concurrently, and running the whole test suite does not oversubscribe the machine. PR-URL: #52177 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
1 parent f6996ee commit bae14b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+79
-67
lines changed

test/es-module/test-cjs-esm-warn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const pjson = path.resolve(
1515
);
1616

1717

18-
describe('CJS ↔︎ ESM interop warnings', { concurrency: true }, () => {
18+
describe('CJS ↔︎ ESM interop warnings', { concurrency: !process.env.TEST_PARALLEL }, () => {
1919

2020
it(async () => {
2121
const required = path.resolve(

test/es-module/test-esm-cjs-exports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { execPath } = require('node:process');
77
const { describe, it } = require('node:test');
88

99

10-
describe('ESM: importing CJS', { concurrency: true }, () => {
10+
describe('ESM: importing CJS', { concurrency: !process.env.TEST_PARALLEL }, () => {
1111
it('should support valid CJS exports', async () => {
1212
const validEntry = fixtures.path('/es-modules/cjs-exports.mjs');
1313
const { code, signal, stdout } = await spawnPromisified(execPath, [validEntry]);

test/es-module/test-esm-cjs-load-error-note.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const mustNotIncludeMessage = {
1919
includeNote: false,
2020
};
2121

22-
describe('ESM: Errors for unexpected exports', { concurrency: true }, () => {
22+
describe('ESM: Errors for unexpected exports', { concurrency: !process.env.TEST_PARALLEL }, () => {
2323
for (
2424
const { errorNeedle, filePath, getMessage, includeNote }
2525
of [

test/es-module/test-esm-detect-ambiguous.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { spawn } from 'node:child_process';
44
import { describe, it } from 'node:test';
55
import { strictEqual, match } from 'node:assert';
66

7-
describe('--experimental-detect-module', { concurrency: true }, () => {
8-
describe('string input', { concurrency: true }, () => {
7+
describe('--experimental-detect-module', { concurrency: !process.env.TEST_PARALLEL }, () => {
8+
describe('string input', { concurrency: !process.env.TEST_PARALLEL }, () => {
99
it('permits ESM syntax in --eval input without requiring --input-type=module', async () => {
1010
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
1111
'--experimental-detect-module',
@@ -72,7 +72,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
7272
});
7373
});
7474

75-
describe('.js file input in a typeless package', { concurrency: true }, () => {
75+
describe('.js file input in a typeless package', { concurrency: !process.env.TEST_PARALLEL }, () => {
7676
for (const { testName, entryPath } of [
7777
{
7878
testName: 'permits CommonJS syntax in a .js entry point',
@@ -114,7 +114,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
114114
}
115115
});
116116

117-
describe('extensionless file input in a typeless package', { concurrency: true }, () => {
117+
describe('extensionless file input in a typeless package', { concurrency: !process.env.TEST_PARALLEL }, () => {
118118
for (const { testName, entryPath } of [
119119
{
120120
testName: 'permits CommonJS syntax in an extensionless entry point',
@@ -179,7 +179,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
179179
});
180180
});
181181

182-
describe('file input in a "type": "commonjs" package', { concurrency: true }, () => {
182+
describe('file input in a "type": "commonjs" package', { concurrency: !process.env.TEST_PARALLEL }, () => {
183183
for (const { testName, entryPath } of [
184184
{
185185
testName: 'disallows ESM syntax in a .js entry point',
@@ -208,7 +208,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
208208
}
209209
});
210210

211-
describe('file input in a "type": "module" package', { concurrency: true }, () => {
211+
describe('file input in a "type": "module" package', { concurrency: !process.env.TEST_PARALLEL }, () => {
212212
for (const { testName, entryPath } of [
213213
{
214214
testName: 'disallows CommonJS syntax in a .js entry point',
@@ -238,7 +238,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
238238
});
239239

240240
// https://github.com/nodejs/node/issues/50917
241-
describe('syntax that errors in CommonJS but works in ESM', { concurrency: true }, () => {
241+
describe('syntax that errors in CommonJS but works in ESM', { concurrency: !process.env.TEST_PARALLEL }, () => {
242242
it('permits top-level `await`', async () => {
243243
const { stdout, stderr, code, signal } = await spawnPromisified(process.execPath, [
244244
'--experimental-detect-module',

test/es-module/test-esm-experimental-warnings.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { execPath } from 'node:process';
55
import { describe, it } from 'node:test';
66

77

8-
describe('ESM: warn for obsolete hooks provided', { concurrency: true }, () => {
8+
describe('ESM: warn for obsolete hooks provided', { concurrency: !process.env.TEST_PARALLEL }, () => {
99
it('should not print warnings when no experimental features are enabled or used', async () => {
1010
const { code, signal, stderr } = await spawnPromisified(execPath, [
1111
'--input-type=module',

test/es-module/test-esm-export-not-found.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const importStatementMultiline = `import {
1212
} from './module-named-exports.mjs';
1313
`;
1414

15-
describe('ESM: nonexistent exports', { concurrency: true }, () => {
15+
describe('ESM: nonexistent exports', { concurrency: !process.env.TEST_PARALLEL }, () => {
1616
for (
1717
const { name, input }
1818
of [

test/es-module/test-esm-extension-lookup-deprecation.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as path from 'node:path';
77
import { execPath } from 'node:process';
88
import { describe, it, before } from 'node:test';
99

10-
describe('ESM in main field', { concurrency: true }, () => {
10+
describe('ESM in main field', { concurrency: !process.env.TEST_PARALLEL }, () => {
1111
before(() => tmpdir.refresh());
1212

1313
it('should handle fully-specified relative path without any warning', async () => {

test/es-module/test-esm-extensionless-esm-and-wasm.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import * as fixtures from '../common/fixtures.mjs';
44
import { describe, it } from 'node:test';
55
import { match, ok, strictEqual } from 'node:assert';
66

7-
describe('extensionless ES modules within a "type": "module" package scope', { concurrency: true }, () => {
7+
describe('extensionless ES modules within a "type": "module" package scope', {
8+
concurrency: !process.env.TEST_PARALLEL,
9+
}, () => {
810
it('should run as the entry point', async () => {
911
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
1012
fixtures.path('es-modules/package-type-module/noext-esm'),
@@ -29,7 +31,9 @@ describe('extensionless ES modules within a "type": "module" package scope', { c
2931
strictEqual(defaultExport, 'module');
3032
});
3133
});
32-
describe('extensionless Wasm modules within a "type": "module" package scope', { concurrency: true }, () => {
34+
describe('extensionless Wasm modules within a "type": "module" package scope', {
35+
concurrency: !process.env.TEST_PARALLEL,
36+
}, () => {
3337
it('should run as the entry point', async () => {
3438
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
3539
'--experimental-wasm-modules',
@@ -55,7 +59,7 @@ describe('extensionless Wasm modules within a "type": "module" package scope', {
5559
});
5660
});
5761

58-
describe('extensionless ES modules within no package scope', { concurrency: true }, () => {
62+
describe('extensionless ES modules within no package scope', { concurrency: !process.env.TEST_PARALLEL }, () => {
5963
// This succeeds with `--experimental-default-type=module`
6064
it('should error as the entry point', async () => {
6165
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
@@ -79,7 +83,7 @@ describe('extensionless ES modules within no package scope', { concurrency: true
7983
});
8084
});
8185

82-
describe('extensionless Wasm within no package scope', { concurrency: true }, () => {
86+
describe('extensionless Wasm within no package scope', { concurrency: !process.env.TEST_PARALLEL }, () => {
8387
// This succeeds with `--experimental-default-type=module`
8488
it('should error as the entry point', async () => {
8589
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [

test/es-module/test-esm-import-flag.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const mjsEntry = fixtures.path('es-modules', 'mjs-file.mjs');
1010
const mjsImport = fixtures.fileURL('es-modules', 'mjs-file.mjs');
1111

1212

13-
describe('import modules using --import', { concurrency: true }, () => {
13+
describe('import modules using --import', { concurrency: !process.env.TEST_PARALLEL }, () => {
1414
it('should import when using --eval', async () => {
1515
const { code, signal, stderr, stdout } = await spawnPromisified(
1616
execPath,

test/es-module/test-esm-import-json-named-export.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { execPath } from 'node:process';
55
import { describe, it } from 'node:test';
66

77

8-
describe('ESM: named JSON exports', { concurrency: true }, () => {
8+
describe('ESM: named JSON exports', { concurrency: !process.env.TEST_PARALLEL }, () => {
99
it('should throw, citing named import', async () => {
1010
const { code, stderr } = await spawnPromisified(execPath, [
1111
fixtures.path('es-modules', 'import-json-named-export.mjs'),

0 commit comments

Comments
 (0)