mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-26 07:57:40 +00:00
test: move vitest config regression under active unit surface
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import baseConfig, { resolveLocalVitestMaxWorkers } from "../vitest.config.ts";
|
||||
|
||||
describe("resolveLocalVitestMaxWorkers", () => {
|
||||
it("uses a moderate local worker cap on larger hosts", () => {
|
||||
expect(
|
||||
resolveLocalVitestMaxWorkers(
|
||||
{
|
||||
RUNNER_OS: "macOS",
|
||||
},
|
||||
{
|
||||
cpuCount: 10,
|
||||
loadAverage1m: 0,
|
||||
totalMemoryBytes: 64 * 1024 ** 3,
|
||||
},
|
||||
),
|
||||
).toBe(3);
|
||||
});
|
||||
|
||||
it("lets OPENCLAW_VITEST_MAX_WORKERS override the inferred cap", () => {
|
||||
expect(
|
||||
resolveLocalVitestMaxWorkers(
|
||||
{
|
||||
OPENCLAW_VITEST_MAX_WORKERS: "2",
|
||||
},
|
||||
{
|
||||
cpuCount: 10,
|
||||
loadAverage1m: 0,
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
platform: "darwin",
|
||||
},
|
||||
),
|
||||
).toBe(2);
|
||||
});
|
||||
|
||||
it("respects the legacy OPENCLAW_TEST_WORKERS override too", () => {
|
||||
expect(
|
||||
resolveLocalVitestMaxWorkers(
|
||||
{
|
||||
OPENCLAW_TEST_WORKERS: "3",
|
||||
},
|
||||
{
|
||||
cpuCount: 16,
|
||||
loadAverage1m: 0,
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
),
|
||||
).toBe(3);
|
||||
});
|
||||
|
||||
it("keeps memory-constrained hosts conservative", () => {
|
||||
expect(
|
||||
resolveLocalVitestMaxWorkers(
|
||||
{},
|
||||
{
|
||||
cpuCount: 16,
|
||||
loadAverage1m: 0,
|
||||
totalMemoryBytes: 16 * 1024 ** 3,
|
||||
},
|
||||
),
|
||||
).toBe(2);
|
||||
});
|
||||
|
||||
it("lets roomy hosts use more local parallelism", () => {
|
||||
expect(
|
||||
resolveLocalVitestMaxWorkers(
|
||||
{},
|
||||
{
|
||||
cpuCount: 16,
|
||||
loadAverage1m: 0,
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
),
|
||||
).toBe(4);
|
||||
});
|
||||
|
||||
it("backs off further when the host is already busy", () => {
|
||||
expect(
|
||||
resolveLocalVitestMaxWorkers(
|
||||
{},
|
||||
{
|
||||
cpuCount: 16,
|
||||
loadAverage1m: 16,
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
),
|
||||
).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("base vitest config", () => {
|
||||
it("excludes fixture trees from test collection", () => {
|
||||
expect(baseConfig.test?.exclude).toContain("test/fixtures/**");
|
||||
});
|
||||
|
||||
it("keeps the base setup file minimal", () => {
|
||||
expect(baseConfig.test?.setupFiles).toEqual(["test/setup.ts"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user