fix(test): reject malformed local check limits

This commit is contained in:
Vincent Koc
2026-06-02 22:48:12 +02:00
parent 6af047c7f6
commit 8cecf2c7ea
4 changed files with 75 additions and 8 deletions
@@ -397,6 +397,25 @@ describe("local-heavy-check-runtime", () => {
expect(fs.existsSync(worktreeLockDir)).toBe(false);
});
it("rejects malformed heavy-check lock timing env values", () => {
const cwd = createTempDir("openclaw-local-heavy-check-malformed-env-");
expect(() =>
acquireLocalHeavyCheckLockSync({
cwd,
env: makeEnv({ OPENCLAW_HEAVY_CHECK_LOCK_TIMEOUT_MS: "10ms" }),
toolName: "oxlint",
}),
).toThrow("OPENCLAW_HEAVY_CHECK_LOCK_TIMEOUT_MS must be a positive integer; got: 10ms");
expect(() =>
acquireLocalHeavyCheckLockSync({
cwd,
env: makeEnv({ OPENCLAW_HEAVY_CHECK_LOCK_POLL_MS: "0" }),
toolName: "oxlint",
}),
).toThrow("OPENCLAW_HEAVY_CHECK_LOCK_POLL_MS must be a positive integer; got: 0");
});
it("cleans up stale legacy test locks when acquiring the shared heavy-check lock", () => {
const cwd = createTempDir("openclaw-local-heavy-check-legacy-");
const commonDir = path.join(cwd, ".git");
@@ -138,4 +138,20 @@ describe("vitest local full-suite profile", () => {
vitestMaxWorkers: 1,
});
});
it("rejects malformed explicit worker limits", () => {
const hostInfo = {
cpuCount: 10,
loadAverage1m: 0,
totalMemoryBytes: 24 * 1024 ** 3,
freeMemoryBytes: 12 * 1024 ** 3,
};
expect(() =>
resolveLocalVitestScheduling({ OPENCLAW_VITEST_MAX_WORKERS: "8x" }, hostInfo, "threads"),
).toThrow("OPENCLAW_VITEST_MAX_WORKERS must be a positive integer; got: 8x");
expect(() =>
resolveLocalVitestScheduling({ OPENCLAW_TEST_WORKERS: "1e0" }, hostInfo, "threads"),
).toThrow("OPENCLAW_TEST_WORKERS must be a positive integer; got: 1e0");
});
});