Skip to content

Commit c72922d

Browse files
authored
chore(tools): run snap-test in parallel on local machines (#257)
CI env still fails, see https://app.graphite.dev/github/pr/voidzero-dev/vite-plus/251/chore(cli)-restore-to-run-snap-test-parallel run 10 times work: `seq 10 | xargs -n 1 sh -c 'pnpm bootstrap-cli && pnpm test && git status'`
1 parent 61f7745 commit c72922d

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

packages/tools/src/snap-test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,26 @@ process.on('exit', () => fs.rmSync(tempTmpDir, { recursive: true, force: true })
3636
const casesDir = path.resolve('snap-tests');
3737

3838
const filter = process.argv[2] ?? ''; // Optional filter to run specific test cases
39+
const isCI = process.env.CI === 'true';
3940

40-
// const tasks: Promise<void>[] = [];
41+
const tasks: Promise<void>[] = [];
4142
for (const caseName of fs.readdirSync(casesDir)) {
4243
if (caseName.startsWith('.')) continue; // Skip hidden files like .DS_Store
4344
if (caseName.includes(filter)) {
44-
// FIXME: parallel run will cause [Error: Broken pipe (os error 32)] { code: 'GenericFailure' }
45-
// tasks.push(runTestCase(caseName));
46-
await runTestCase(caseName);
45+
if (isCI) {
46+
// FIXME: parallel run will cause panicked: Access tokio runtime failed in spawn, maybe related to napi-3.3.0/src/tokio_runtime.rs:113:6
47+
// see https://app.graphite.dev/github/pr/voidzero-dev/vite-plus/251/chore(cli)-restore-to-run-snap-test-parallel
48+
await runTestCase(caseName);
49+
} else {
50+
// let snap-test run faster on local machine
51+
tasks.push(runTestCase(caseName));
52+
}
4753
}
4854
}
4955

50-
// await Promise.all(tasks);
51-
56+
if (tasks.length > 0) {
57+
await Promise.all(tasks);
58+
}
5259
interface Steps {
5360
ignoredPlatforms?: string[];
5461
env: Record<string, string>;

0 commit comments

Comments
 (0)