fix(qa): reject duplicate model bench controls · openclaw/openclaw@b22ae2a
vincentkoc
·
2026-06-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -40,12 +40,17 @@ function readValue(argv: string[], index: number, flag: string): string {
|
40 | 40 | } |
41 | 41 | |
42 | 42 | function validateCliArgs(argv: string[]): void { |
| 43 | +const seenValueFlags = new Set<string>(); |
43 | 44 | for (let index = 0; index < argv.length; index += 1) { |
44 | 45 | const arg = argv[index] ?? ""; |
45 | 46 | if (BOOLEAN_FLAGS.has(arg)) { |
46 | 47 | continue; |
47 | 48 | } |
48 | 49 | if (VALUE_FLAGS.has(arg)) { |
| 50 | +if (seenValueFlags.has(arg)) { |
| 51 | +throw new CliArgumentError(`${arg} was provided more than once`); |
| 52 | +} |
| 53 | +seenValueFlags.add(arg); |
49 | 54 | readValue(argv, index, arg); |
50 | 55 | index += 1; |
51 | 56 | continue; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -59,6 +59,20 @@ describe("scripts/bench-model", () => {
|
59 | 59 | expect(result.stderr).not.toContain("Missing ANTHROPIC_API_KEY"); |
60 | 60 | }); |
61 | 61 | |
| 62 | +it("rejects duplicate value flags before checking provider credentials", () => { |
| 63 | +expect(() => testing.parseArgs(["--runs", "1", "--runs", "2"])).toThrow( |
| 64 | +"--runs was provided more than once", |
| 65 | +); |
| 66 | + |
| 67 | +const result = runBenchModel(["--runs", "1", "--runs", "2"]); |
| 68 | + |
| 69 | +expect(result.status).toBe(1); |
| 70 | +expect(result.stdout).toBe(""); |
| 71 | +expect(result.stderr.trim()).toBe("--runs was provided more than once"); |
| 72 | +expect(result.stderr).not.toContain("Missing ANTHROPIC_API_KEY"); |
| 73 | +expect(result.stderr).not.toContain("\n at "); |
| 74 | +}); |
| 75 | + |
62 | 76 | it("prints help without checking provider credentials", () => { |
63 | 77 | const result = runBenchModel(["--help"]); |
64 | 78 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。