From 88f94d5b610ae3aed1381f545170fada7e388abb Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 1 Sep 2023 01:25:18 -0500 Subject: [PATCH] test(server): run test in single thread (#4095) --- apps/server/scripts/run-test.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/server/scripts/run-test.ts b/apps/server/scripts/run-test.ts index efdfc4eec4..b732d5feaa 100755 --- a/apps/server/scripts/run-test.ts +++ b/apps/server/scripts/run-test.ts @@ -2,12 +2,13 @@ import { resolve } from 'node:path'; import * as p from '@clack/prompts'; -import { spawn } from 'child_process'; +import { spawn, spawnSync } from 'child_process'; import { readdir } from 'fs/promises'; import * as process from 'process'; import { fileURLToPath } from 'url'; import pkg from '../package.json' assert { type: 'json' }; + const root = fileURLToPath(new URL('..', import.meta.url)); const testDir = resolve(root, 'src', 'tests'); const files = await readdir(testDir); @@ -28,14 +29,14 @@ const env = { }; if (process.argv[2] === 'all') { - const cp = spawn('node', [...sharedArgs, resolve(testDir, '*')], { - cwd: root, - env, - stdio: 'inherit', - shell: true, - }); - cp.on('exit', code => { - process.exit(code ?? 0); + files.forEach(file => { + const path = resolve(testDir, file); + spawnSync('node', [...sharedArgs, path], { + cwd: root, + env, + stdio: 'inherit', + shell: true, + }); }); } else { const result = await p.group({