mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00: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>
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
import { spawnPromisified } from '../common/index.mjs';
|
|
import { spawn } from 'node:child_process';
|
|
import { describe, it } from 'node:test';
|
|
import { strictEqual, match } from 'node:assert';
|
|
|
|
describe('the type flag should change the interpretation of string input', {
|
|
concurrency: !process.env.TEST_PARALLEL,
|
|
}, () => {
|
|
it('should run as ESM input passed via --eval', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
'--eval',
|
|
'import "data:text/javascript,console.log(42)"',
|
|
]);
|
|
|
|
strictEqual(stderr, '');
|
|
strictEqual(stdout, '42\n');
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
});
|
|
|
|
// ESM is unsupported for --print via --input-type=module
|
|
|
|
it('should run as ESM input passed via STDIN', async () => {
|
|
const child = spawn(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
]);
|
|
child.stdin.end('console.log(typeof import.meta.resolve)');
|
|
|
|
match((await child.stdout.toArray()).toString(), /^function\r?\n$/);
|
|
});
|
|
|
|
it('should be overridden by --input-type', async () => {
|
|
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
|
|
'--experimental-default-type=module',
|
|
'--input-type=commonjs',
|
|
'--eval',
|
|
'console.log(require("process").version)',
|
|
]);
|
|
|
|
strictEqual(stderr, '');
|
|
strictEqual(stdout, `${process.version}\n`);
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
});
|
|
});
|