fix(qa): reject duplicate sqlite bench controls

This commit is contained in:
Vincent Koc
2026-06-23 16:41:01 +02:00
parent 8c09419f20
commit bde5be874a
2 changed files with 13 additions and 0 deletions

View File

@@ -134,12 +134,17 @@ function hasFlag(flag: string, argv = process.argv.slice(2)): boolean {
}
function validateArgs(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 CliUsageError(`${arg} was provided more than once`);
}
seenValueFlags.add(arg);
const value = argv[index + 1];
if (!value || value.startsWith("-")) {
throw new CliUsageError(`${arg} requires a value`);

View File

@@ -47,4 +47,12 @@ describe("scripts/bench-sqlite-state", () => {
'error: --profile must be one of smoke, default, large; got "huge"',
);
});
it("rejects duplicate single-value controls before seeding benchmark databases", () => {
const result = runBench(["--profile", "smoke", "--profile", "large"]);
expect(result.status).toBe(2);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("error: --profile was provided more than once");
});
});