diff --git a/vitest.workers.test.ts b/vitest.workers.test.ts index 64ece8f..8232b3a 100644 --- a/vitest.workers.test.ts +++ b/vitest.workers.test.ts @@ -79,7 +79,7 @@ describe("localWorkerLimit", () => { }); it("takes the configured want and a second call reuses the same grant", async () => { - const env = { VITEST_HOST_WORKERS: "6", VITEST_MAX_WORKERS: "4" }; + const env = { VITEST_HOST_WORKERS: "6", VITEST_LOCAL_MAX_WORKERS: "4" }; expect(await localWorkerLimit({ env, dir, log: quiet })).toEqual({ maxWorkers: 4, }); @@ -104,7 +104,7 @@ describe("localWorkerLimit", () => { } resetLocalGrantForTests(); const capped = await localWorkerLimit({ - env: { VITEST_HOST_WORKERS: "6", VITEST_MAX_WORKERS: "10" }, + env: { VITEST_HOST_WORKERS: "6", VITEST_LOCAL_MAX_WORKERS: "10" }, dir, log: quiet, }); @@ -128,7 +128,7 @@ describe("localWorkerLimit grant sharing and fallback", () => { const warnings: string[] = []; try { const result = await localWorkerLimit({ - env: { VITEST_MAX_WORKERS: "3" }, + env: { VITEST_LOCAL_MAX_WORKERS: "3" }, dir: join(parent, "sub", "slots"), log: (m) => warnings.push(m), }); diff --git a/vitest.workers.ts b/vitest.workers.ts index 9e0cd35..70c3d4e 100644 --- a/vitest.workers.ts +++ b/vitest.workers.ts @@ -3,9 +3,10 @@ // user share a budget of slot directories under /tmp (default 6 workers in // total); a run that finds none free waits. In CI (CI set) nothing changes. // -// Env: VITEST_HOST_WORKERS (budget, default 6), VITEST_MAX_WORKERS (workers +// Env: VITEST_HOST_WORKERS (budget, default 6), VITEST_LOCAL_MAX_WORKERS (workers // wanted by one run, default 6, capped by the budget). `--maxWorkers` on the // vitest command line still overrides the config. +// Not VITEST_MAX_WORKERS: vitest 4 reads that itself and would bypass the host budget. // // Keep this file free of TypeScript-only runtime syntax (enums, parameter // properties): the cross-process test loads it with Node's type stripping. @@ -216,7 +217,7 @@ export async function localWorkerLimit( if (env.CI) return {}; const budget = positiveInt(env.VITEST_HOST_WORKERS, DEFAULT_BUDGET); const want = Math.min( - positiveInt(env.VITEST_MAX_WORKERS, DEFAULT_BUDGET), + positiveInt(env.VITEST_LOCAL_MAX_WORKERS, DEFAULT_BUDGET), budget, ); const g = globalThis as WithGrant;