mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(docker): reject malformed timing limits
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// Accepts scheduler summary.json or lane-timings.json so agents can see the
|
||||
// slowest lanes and phase critical path before deciding what to rerun.
|
||||
import fs from "node:fs";
|
||||
import { parsePositiveInt } from "./lib/numeric-options.mjs";
|
||||
|
||||
function usage() {
|
||||
return "Usage: node scripts/docker-e2e-timings.mjs <summary.json|lane-timings.json> [--limit N]";
|
||||
@@ -15,9 +16,9 @@ function parseArgs(argv) {
|
||||
if (arg === "--help" || arg === "-h") {
|
||||
options.help = true;
|
||||
} else if (arg === "--limit") {
|
||||
options.limit = Number(argv[(index += 1)] ?? "");
|
||||
options.limit = parsePositiveInt(argv[(index += 1)], "--limit");
|
||||
} else if (arg?.startsWith("--limit=")) {
|
||||
options.limit = Number(arg.slice("--limit=".length));
|
||||
options.limit = parsePositiveInt(arg.slice("--limit=".length), "--limit");
|
||||
} else if (!options.file) {
|
||||
options.file = arg;
|
||||
} else {
|
||||
@@ -27,7 +28,7 @@ function parseArgs(argv) {
|
||||
if (options.help) {
|
||||
return options;
|
||||
}
|
||||
if (!options.file || !Number.isInteger(options.limit) || options.limit < 1) {
|
||||
if (!options.file) {
|
||||
throw new Error(usage());
|
||||
}
|
||||
return options;
|
||||
|
||||
@@ -42,6 +42,16 @@ describe("Docker E2E helper CLIs", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects malformed timings limits without a Node stack trace", () => {
|
||||
const result = runHelper("scripts/docker-e2e-timings.mjs", "summary.json", "--limit=1e3");
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toBe("");
|
||||
expect(result.stderr).toContain("--limit must be a positive integer");
|
||||
expect(result.stderr).not.toContain("Error:");
|
||||
expect(result.stderr).not.toContain("at file:");
|
||||
});
|
||||
|
||||
it("prints rerun help without detecting the GitHub repository", () => {
|
||||
const result = runHelper("scripts/docker-e2e-rerun.mjs", "--help");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user