mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 00:11:19 +00:00
fix(qa): reject duplicate model bench controls
This commit is contained in:
parent
a822c9abaa
commit
b22ae2a4da
2 changed files with 19 additions and 0 deletions
|
|
@ -40,12 +40,17 @@ function readValue(argv: string[], index: number, flag: string): string {
|
|||
}
|
||||
|
||||
function validateCliArgs(argv: string[]): void {
|
||||
const seenValueFlags = new Set<string>();
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index] ?? "";
|
||||
if (BOOLEAN_FLAGS.has(arg)) {
|
||||
continue;
|
||||
}
|
||||
if (VALUE_FLAGS.has(arg)) {
|
||||
if (seenValueFlags.has(arg)) {
|
||||
throw new CliArgumentError(`${arg} was provided more than once`);
|
||||
}
|
||||
seenValueFlags.add(arg);
|
||||
readValue(argv, index, arg);
|
||||
index += 1;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,20 @@ describe("scripts/bench-model", () => {
|
|||
expect(result.stderr).not.toContain("Missing ANTHROPIC_API_KEY");
|
||||
});
|
||||
|
||||
it("rejects duplicate value flags before checking provider credentials", () => {
|
||||
expect(() => testing.parseArgs(["--runs", "1", "--runs", "2"])).toThrow(
|
||||
"--runs was provided more than once",
|
||||
);
|
||||
|
||||
const result = runBenchModel(["--runs", "1", "--runs", "2"]);
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toBe("");
|
||||
expect(result.stderr.trim()).toBe("--runs was provided more than once");
|
||||
expect(result.stderr).not.toContain("Missing ANTHROPIC_API_KEY");
|
||||
expect(result.stderr).not.toContain("\n at ");
|
||||
});
|
||||
|
||||
it("prints help without checking provider credentials", () => {
|
||||
const result = runBenchModel(["--help"]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue