mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
test: speed up test suite and trim redundant onboarding tests
This commit is contained in:
@@ -5,19 +5,24 @@ import path from "node:path";
|
||||
|
||||
const pnpm = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
||||
|
||||
const runs = [
|
||||
{
|
||||
name: "unit",
|
||||
args: ["vitest", "run", "--config", "vitest.unit.config.ts"],
|
||||
},
|
||||
{
|
||||
name: "extensions",
|
||||
args: ["vitest", "run", "--config", "vitest.extensions.config.ts"],
|
||||
},
|
||||
{
|
||||
name: "gateway",
|
||||
args: ["vitest", "run", "--config", "vitest.gateway.config.ts"],
|
||||
},
|
||||
const unitIsolatedFiles = [
|
||||
"src/plugins/loader.test.ts",
|
||||
"src/plugins/tools.optional.test.ts",
|
||||
"src/agents/session-tool-result-guard.tool-result-persist-hook.test.ts",
|
||||
"src/security/fix.test.ts",
|
||||
"src/utils.test.ts",
|
||||
"src/auto-reply/tool-meta.test.ts",
|
||||
"src/commands/auth-choice.test.ts",
|
||||
"src/media/store.header-ext.test.ts",
|
||||
"src/browser/server.covers-additional-endpoint-branches.test.ts",
|
||||
"src/browser/server.post-tabs-open-profile-unknown-returns-404.test.ts",
|
||||
"src/browser/server.agent-contract-snapshot-endpoints.test.ts",
|
||||
"src/browser/server.agent-contract-form-layout-act-commands.test.ts",
|
||||
"src/browser/server.serves-status-starts-browser-requested.test.ts",
|
||||
"src/browser/server.skips-default-maxchars-explicitly-set-zero.test.ts",
|
||||
"src/browser/server.auth-token-gates-http.test.ts",
|
||||
"src/browser/server-context.remote-tab-ops.test.ts",
|
||||
"src/browser/server-context.ensure-tab-available.prefers-last-target.test.ts",
|
||||
];
|
||||
|
||||
const children = new Set();
|
||||
@@ -25,6 +30,62 @@ const isCI = process.env.CI === "true" || process.env.GITHUB_ACTIONS === "true";
|
||||
const isMacOS = process.platform === "darwin" || process.env.RUNNER_OS === "macOS";
|
||||
const isWindows = process.platform === "win32" || process.env.RUNNER_OS === "Windows";
|
||||
const isWindowsCi = isCI && isWindows;
|
||||
const useVmForks =
|
||||
process.env.OPENCLAW_TEST_VM_FORKS === "1" ||
|
||||
(process.env.OPENCLAW_TEST_VM_FORKS !== "0" && !isWindows);
|
||||
const runs = [
|
||||
...(useVmForks
|
||||
? [
|
||||
{
|
||||
name: "unit-fast",
|
||||
args: [
|
||||
"vitest",
|
||||
"run",
|
||||
"--config",
|
||||
"vitest.unit.config.ts",
|
||||
"--pool=vmForks",
|
||||
...unitIsolatedFiles.flatMap((file) => ["--exclude", file]),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "unit-isolated",
|
||||
args: [
|
||||
"vitest",
|
||||
"run",
|
||||
"--config",
|
||||
"vitest.unit.config.ts",
|
||||
"--pool=forks",
|
||||
...unitIsolatedFiles,
|
||||
],
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
name: "unit",
|
||||
args: ["vitest", "run", "--config", "vitest.unit.config.ts"],
|
||||
},
|
||||
]),
|
||||
{
|
||||
name: "extensions",
|
||||
args: [
|
||||
"vitest",
|
||||
"run",
|
||||
"--config",
|
||||
"vitest.extensions.config.ts",
|
||||
...(useVmForks ? ["--pool=vmForks"] : []),
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "gateway",
|
||||
args: [
|
||||
"vitest",
|
||||
"run",
|
||||
"--config",
|
||||
"vitest.gateway.config.ts",
|
||||
...(useVmForks ? ["--pool=vmForks"] : []),
|
||||
],
|
||||
},
|
||||
];
|
||||
const shardOverride = Number.parseInt(process.env.OPENCLAW_TEST_SHARDS ?? "", 10);
|
||||
const shardCount = isWindowsCi
|
||||
? Number.isFinite(shardOverride) && shardOverride > 1
|
||||
@@ -40,12 +101,12 @@ const passthroughArgs =
|
||||
const overrideWorkers = Number.parseInt(process.env.OPENCLAW_TEST_WORKERS ?? "", 10);
|
||||
const resolvedOverride =
|
||||
Number.isFinite(overrideWorkers) && overrideWorkers > 0 ? overrideWorkers : null;
|
||||
// Keep gateway serial by default to avoid resource contention with unit/extensions.
|
||||
// Allow explicit opt-in parallel runs on non-Windows CI/local when requested.
|
||||
// Keep gateway serial on Windows CI and CI by default; run in parallel locally
|
||||
// for lower wall-clock time. CI can opt in via OPENCLAW_TEST_PARALLEL_GATEWAY=1.
|
||||
const keepGatewaySerial =
|
||||
isWindowsCi ||
|
||||
process.env.OPENCLAW_TEST_SERIAL_GATEWAY === "1" ||
|
||||
process.env.OPENCLAW_TEST_PARALLEL_GATEWAY !== "1";
|
||||
(isCI && process.env.OPENCLAW_TEST_PARALLEL_GATEWAY !== "1");
|
||||
const parallelRuns = keepGatewaySerial ? runs.filter((entry) => entry.name !== "gateway") : runs;
|
||||
const serialRuns = keepGatewaySerial ? runs.filter((entry) => entry.name === "gateway") : [];
|
||||
const localWorkers = Math.max(4, Math.min(16, os.cpus().length));
|
||||
@@ -65,6 +126,9 @@ const maxWorkersForRun = (name) => {
|
||||
if (isCI && isMacOS) {
|
||||
return 1;
|
||||
}
|
||||
if (name === "unit-isolated") {
|
||||
return 1;
|
||||
}
|
||||
if (name === "extensions") {
|
||||
return defaultExtensionsWorkers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user