test(server): run test in single thread (#4095)
This commit is contained in:
@@ -2,12 +2,13 @@
|
|||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
|
|
||||||
import * as p from '@clack/prompts';
|
import * as p from '@clack/prompts';
|
||||||
import { spawn } from 'child_process';
|
import { spawn, spawnSync } from 'child_process';
|
||||||
import { readdir } from 'fs/promises';
|
import { readdir } from 'fs/promises';
|
||||||
import * as process from 'process';
|
import * as process from 'process';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
import pkg from '../package.json' assert { type: 'json' };
|
import pkg from '../package.json' assert { type: 'json' };
|
||||||
|
|
||||||
const root = fileURLToPath(new URL('..', import.meta.url));
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
||||||
const testDir = resolve(root, 'src', 'tests');
|
const testDir = resolve(root, 'src', 'tests');
|
||||||
const files = await readdir(testDir);
|
const files = await readdir(testDir);
|
||||||
@@ -28,14 +29,14 @@ const env = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (process.argv[2] === 'all') {
|
if (process.argv[2] === 'all') {
|
||||||
const cp = spawn('node', [...sharedArgs, resolve(testDir, '*')], {
|
files.forEach(file => {
|
||||||
|
const path = resolve(testDir, file);
|
||||||
|
spawnSync('node', [...sharedArgs, path], {
|
||||||
cwd: root,
|
cwd: root,
|
||||||
env,
|
env,
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
cp.on('exit', code => {
|
|
||||||
process.exit(code ?? 0);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const result = await p.group({
|
const result = await p.group({
|
||||||
|
|||||||
Reference in New Issue
Block a user