|
6 | 6 | buildFullSuiteVitestRunPlans, |
7 | 7 | createVitestRunSpecs, |
8 | 8 | parseTestProjectsArgs, |
| 9 | + resolveParallelFullSuiteConcurrency, |
9 | 10 | resolveChangedTargetArgs, |
10 | | - shouldUseLocalFullSuiteParallelByDefault, |
11 | 11 | writeVitestIncludeFile, |
12 | 12 | } from "./test-projects.test-support.mjs"; |
13 | 13 | import { |
@@ -116,29 +116,17 @@ function runVitestSpec(spec) { |
116 | 116 | }); |
117 | 117 | } |
118 | 118 |
|
119 | | -function parsePositiveInt(value) { |
120 | | - const parsed = Number.parseInt(value ?? "", 10); |
121 | | - return Number.isFinite(parsed) && parsed > 0 ? parsed : null; |
122 | | -} |
123 | | - |
124 | | -function resolveParallelFullSuiteConcurrency(specCount, env) { |
125 | | - const override = parsePositiveInt(env.OPENCLAW_TEST_PROJECTS_PARALLEL); |
126 | | - if (override !== null) { |
127 | | - return Math.min(override, specCount); |
128 | | - } |
129 | | - if (env.OPENCLAW_TEST_PROJECTS_SERIAL === "1") { |
130 | | - return 1; |
| 119 | +function applyDefaultParallelVitestWorkerBudget(specs, env) { |
| 120 | + if (env.OPENCLAW_VITEST_MAX_WORKERS || env.OPENCLAW_TEST_WORKERS) { |
| 121 | + return specs; |
131 | 122 | } |
132 | | - if (env.CI === "true" || env.GITHUB_ACTIONS === "true") { |
133 | | - return 1; |
134 | | - } |
135 | | - if ( |
136 | | - env.OPENCLAW_TEST_PROJECTS_LEAF_SHARDS !== "1" && |
137 | | - !shouldUseLocalFullSuiteParallelByDefault(env) |
138 | | - ) { |
139 | | - return 1; |
140 | | - } |
141 | | - return 1; |
| 123 | + return specs.map((spec) => ({ |
| 124 | + ...spec, |
| 125 | + env: { |
| 126 | + ...spec.env, |
| 127 | + OPENCLAW_VITEST_MAX_WORKERS: "2", |
| 128 | + }, |
| 129 | + })); |
142 | 130 | } |
143 | 131 |
|
144 | 132 | function orderFullSuiteSpecsForParallelRun(specs) { |
@@ -218,7 +206,10 @@ async function main() { |
218 | 206 | if (isFullSuiteRun) { |
219 | 207 | const concurrency = resolveParallelFullSuiteConcurrency(runSpecs.length, process.env); |
220 | 208 | if (concurrency > 1) { |
221 | | - const parallelSpecs = orderFullSuiteSpecsForParallelRun(runSpecs); |
| 209 | + const parallelSpecs = applyDefaultParallelVitestWorkerBudget( |
| 210 | + orderFullSuiteSpecsForParallelRun(runSpecs), |
| 211 | + process.env, |
| 212 | + ); |
222 | 213 | console.error( |
223 | 214 | `[test] running ${parallelSpecs.length} Vitest shards with parallelism ${concurrency}`, |
224 | 215 | ); |
|
0 commit comments