fix(qa): reject duplicate model bench controls

This commit is contained in:
Vincent Koc 2026-06-23 17:18:47 +02:00
parent a822c9abaa
commit b22ae2a4da
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

View file

@ -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;

View file

@ -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"]);