mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
bae14b7914
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: https://github.com/nodejs/node/pull/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>
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
import '../common/index.mjs';
|
|
import * as fixtures from '../common/fixtures.mjs';
|
|
import * as snapshot from '../common/assertSnapshot.js';
|
|
import { describe, it } from 'node:test';
|
|
|
|
const skipForceColors =
|
|
process.config.variables.icu_gyp_path !== 'tools/icu/icu-generic.gyp' ||
|
|
process.config.variables.node_shared_openssl;
|
|
|
|
function replaceStackTrace(str) {
|
|
return snapshot.replaceStackTrace(str, '$1at *$7\n');
|
|
}
|
|
|
|
describe('console output', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
|
function normalize(str) {
|
|
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(process.version, '*').replaceAll(/\d+/g, '*');
|
|
}
|
|
const tests = [
|
|
{ name: 'console/2100bytes.js' },
|
|
{ name: 'console/console_low_stack_space.js' },
|
|
{ name: 'console/console.js' },
|
|
{ name: 'console/hello_world.js' },
|
|
{
|
|
name: 'console/stack_overflow.js',
|
|
transform: snapshot
|
|
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize)
|
|
},
|
|
!skipForceColors ? { name: 'console/force_colors.js', env: { FORCE_COLOR: 1 } } : null,
|
|
].filter(Boolean);
|
|
const defaultTransform = snapshot
|
|
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace);
|
|
for (const { name, transform, env } of tests) {
|
|
it(name, async () => {
|
|
await snapshot.spawnAndAssert(
|
|
fixtures.path(name),
|
|
transform ?? defaultTransform,
|
|
{ env: { ...env, ...process.env } },
|
|
);
|
|
});
|
|
}
|
|
});
|