test(e2e): serialize default e2e runner · openclaw/openclaw@120eb34
vincentkoc
·
2026-05-07
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,7 +4,7 @@ import {
|
4 | 4 | normalizeConfigPaths, |
5 | 5 | } from "../../test/helpers/vitest-config-paths.js"; |
6 | 6 | import { BUNDLED_PLUGIN_E2E_TEST_GLOB } from "../../test/vitest/vitest.bundled-plugin-paths.ts"; |
7 | | -import e2eConfig from "../../test/vitest/vitest.e2e.config.ts"; |
| 7 | +import e2eConfig, { resolveE2EWorkerCount } from "../../test/vitest/vitest.e2e.config.ts"; |
8 | 8 | |
9 | 9 | describe("e2e vitest config", () => { |
10 | 10 | it("runs as a standalone config instead of inheriting unit projects", () => { |
@@ -28,4 +28,12 @@ describe("e2e vitest config", () => {
|
28 | 28 | "test/setup-openclaw-runtime.ts", |
29 | 29 | ); |
30 | 30 | }); |
| 31 | + |
| 32 | +it("serializes default e2e runs while preserving explicit worker overrides", () => { |
| 33 | +expect(e2eConfig.test?.maxWorkers).toBe(1); |
| 34 | +expect(resolveE2EWorkerCount({})).toBe(1); |
| 35 | +expect(resolveE2EWorkerCount({ OPENCLAW_E2E_WORKERS: "4" })).toBe(4); |
| 36 | +expect(resolveE2EWorkerCount({ OPENCLAW_E2E_WORKERS: "99" })).toBe(16); |
| 37 | +expect(resolveE2EWorkerCount({ OPENCLAW_E2E_WORKERS: "0" })).toBe(1); |
| 38 | +}); |
31 | 39 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import os from "node:os"; |
2 | 1 | import { defineConfig } from "vitest/config"; |
3 | 2 | import { BUNDLED_PLUGIN_E2E_TEST_GLOB } from "./vitest.bundled-plugin-paths.ts"; |
4 | 3 | import baseConfig from "./vitest.config.ts"; |
5 | 4 | import { resolveRepoRootPath } from "./vitest.shared.config.ts"; |
6 | 5 | |
7 | | -const base = baseConfig as unknown as Record<string, unknown>; |
8 | | -const isCI = process.env.CI === "true" || process.env.GITHUB_ACTIONS === "true"; |
9 | | -const cpuCount = os.cpus().length; |
10 | | -// Keep e2e runs cheap by default; callers can still override via OPENCLAW_E2E_WORKERS. |
11 | | -const defaultWorkers = isCI ? Math.min(2, Math.max(1, Math.floor(cpuCount * 0.25))) : 1; |
12 | | -const requestedWorkers = Number.parseInt(process.env.OPENCLAW_E2E_WORKERS ?? "", 10); |
13 | | -const e2eWorkers = |
14 | | -Number.isFinite(requestedWorkers) && requestedWorkers > 0 |
| 6 | +type E2EWorkerEnv = { |
| 7 | +OPENCLAW_E2E_WORKERS?: string; |
| 8 | +}; |
| 9 | + |
| 10 | +export function resolveE2EWorkerCount(env: E2EWorkerEnv = process.env): number { |
| 11 | +const requestedWorkers = Number.parseInt(env.OPENCLAW_E2E_WORKERS ?? "", 10); |
| 12 | +return Number.isFinite(requestedWorkers) && requestedWorkers > 0 |
15 | 13 | ? Math.min(16, requestedWorkers) |
16 | | - : defaultWorkers; |
| 14 | + : 1; |
| 15 | +} |
| 16 | + |
| 17 | +const base = baseConfig as unknown as Record<string, unknown>; |
| 18 | +// Keep e2e runs deterministic by default; callers can still opt into parallelism. |
| 19 | +const e2eWorkers = resolveE2EWorkerCount(); |
17 | 20 | const verboseE2E = process.env.OPENCLAW_E2E_VERBOSE === "1"; |
18 | 21 | |
19 | 22 | const baseTestWithProjects = |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。