mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-26 06:39:35 +00:00
fix(qa): reject duplicate sqlite bench controls
This commit is contained in:
@@ -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`);
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user