Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vitest.workers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -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,
});
Expand All @@ -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),
});
Expand Down
5 changes: 3 additions & 2 deletions vitest.workers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
Loading