fix(test): reject malformed extension shard counts · openclaw/openclaw@432a597
vincentkoc
·
2026-06-03
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,7 @@ import { isWhatsAppExtensionRoot } from "../../test/vitest/vitest.extension-what
|
26 | 26 | import { isZaloExtensionRoot } from "../../test/vitest/vitest.extension-zalo-paths.mjs"; |
27 | 27 | import { BUNDLED_PLUGIN_PATH_PREFIX, BUNDLED_PLUGIN_ROOT_DIR } from "./bundled-plugin-paths.mjs"; |
28 | 28 | import { listAvailableExtensionIds } from "./changed-extensions.mjs"; |
| 29 | +import { parsePositiveInt } from "./numeric-options.mjs"; |
29 | 30 | |
30 | 31 | const repoRoot = path.resolve(import.meta.dirname, "..", ".."); |
31 | 32 | export const DEFAULT_EXTENSION_TEST_SHARD_COUNT = 8; |
@@ -359,7 +360,8 @@ function pickLeastLoadedShard(shards) {
|
359 | 360 | export function createExtensionTestShards(params = {}) { |
360 | 361 | const cwd = params.cwd ?? process.cwd(); |
361 | 362 | const extensionIds = params.extensionIds ?? listAvailableExtensionIds(); |
362 | | -const shardCount = Math.max(1, Number.parseInt(String(params.shardCount ?? ""), 10) || 1); |
| 363 | +const shardCount = |
| 364 | +params.shardCount === undefined ? 1 : parsePositiveInt(params.shardCount, "shardCount"); |
363 | 365 | const plans = extensionIds |
364 | 366 | .map((extensionId) => resolveExtensionTestPlan({ cwd, targetArg: extensionId })) |
365 | 367 | .filter((plan) => plan.hasTests) |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -530,6 +530,16 @@ describe("scripts/test-extension.mjs", () => {
|
530 | 530 | } |
531 | 531 | }); |
532 | 532 | |
| 533 | +it("rejects malformed extension shard counts", () => { |
| 534 | +expect(() => |
| 535 | +createExtensionTestShards({ |
| 536 | +cwd: process.cwd(), |
| 537 | +extensionIds: ["matrix", "openai"], |
| 538 | +shardCount: "2x", |
| 539 | +}), |
| 540 | +).toThrow("shardCount must be a positive integer"); |
| 541 | +}); |
| 542 | + |
533 | 543 | it("runs extension batch config groups concurrently when requested", async () => { |
534 | 544 | const started: string[] = []; |
535 | 545 | const resolvers: Array<() => void> = []; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。