fix(docker): reject malformed timing limits · openclaw/openclaw@aed3743
vincentkoc
·
2026-06-03
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@
|
3 | 3 | // Accepts scheduler summary.json or lane-timings.json so agents can see the |
4 | 4 | // slowest lanes and phase critical path before deciding what to rerun. |
5 | 5 | import fs from "node:fs"; |
| 6 | +import { parsePositiveInt } from "./lib/numeric-options.mjs"; |
6 | 7 | |
7 | 8 | function usage() { |
8 | 9 | return "Usage: node scripts/docker-e2e-timings.mjs <summary.json|lane-timings.json> [--limit N]"; |
@@ -15,9 +16,9 @@ function parseArgs(argv) {
|
15 | 16 | if (arg === "--help" || arg === "-h") { |
16 | 17 | options.help = true; |
17 | 18 | } else if (arg === "--limit") { |
18 | | -options.limit = Number(argv[(index += 1)] ?? ""); |
| 19 | +options.limit = parsePositiveInt(argv[(index += 1)], "--limit"); |
19 | 20 | } else if (arg?.startsWith("--limit=")) { |
20 | | -options.limit = Number(arg.slice("--limit=".length)); |
| 21 | +options.limit = parsePositiveInt(arg.slice("--limit=".length), "--limit"); |
21 | 22 | } else if (!options.file) { |
22 | 23 | options.file = arg; |
23 | 24 | } else { |
@@ -27,7 +28,7 @@ function parseArgs(argv) {
|
27 | 28 | if (options.help) { |
28 | 29 | return options; |
29 | 30 | } |
30 | | -if (!options.file || !Number.isInteger(options.limit) || options.limit < 1) { |
| 31 | +if (!options.file) { |
31 | 32 | throw new Error(usage()); |
32 | 33 | } |
33 | 34 | return options; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,16 @@ describe("Docker E2E helper CLIs", () => {
|
42 | 42 | ); |
43 | 43 | }); |
44 | 44 | |
| 45 | +it("rejects malformed timings limits without a Node stack trace", () => { |
| 46 | +const result = runHelper("scripts/docker-e2e-timings.mjs", "summary.json", "--limit=1e3"); |
| 47 | + |
| 48 | +expect(result.status).toBe(1); |
| 49 | +expect(result.stdout).toBe(""); |
| 50 | +expect(result.stderr).toContain("--limit must be a positive integer"); |
| 51 | +expect(result.stderr).not.toContain("Error:"); |
| 52 | +expect(result.stderr).not.toContain("at file:"); |
| 53 | +}); |
| 54 | + |
45 | 55 | it("prints rerun help without detecting the GitHub repository", () => { |
46 | 56 | const result = runHelper("scripts/docker-e2e-rerun.mjs", "--help"); |
47 | 57 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。