mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
fix(qa): reject duplicate abort leak controls
This commit is contained in:
parent
bde5be874a
commit
e9b017d9dc
2 changed files with 35 additions and 0 deletions
|
|
@ -34,6 +34,16 @@ type Options = {
|
||||||
quiet: boolean;
|
quiet: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const VALUE_FLAGS = new Set([
|
||||||
|
"--iters",
|
||||||
|
"--batches",
|
||||||
|
"--snap-dir",
|
||||||
|
"--mode",
|
||||||
|
"--max-rss-growth-mb",
|
||||||
|
"--max-tracked-retention",
|
||||||
|
"--scope-bytes",
|
||||||
|
]);
|
||||||
|
|
||||||
function readValue(raw: string | undefined, flag: string): string {
|
function readValue(raw: string | undefined, flag: string): string {
|
||||||
const value = raw?.trim() ?? "";
|
const value = raw?.trim() ?? "";
|
||||||
if (!value || value.startsWith("-")) {
|
if (!value || value.startsWith("-")) {
|
||||||
|
|
@ -53,9 +63,16 @@ function parseArgs(argv: string[]): Options {
|
||||||
scopeBytes: 2_000_000,
|
scopeBytes: 2_000_000,
|
||||||
quiet: false,
|
quiet: false,
|
||||||
};
|
};
|
||||||
|
const seenValueFlags = new Set<string>();
|
||||||
for (let i = 0; i < argv.length; i += 1) {
|
for (let i = 0; i < argv.length; i += 1) {
|
||||||
const arg = argv[i];
|
const arg = argv[i];
|
||||||
const next = argv[i + 1];
|
const next = argv[i + 1];
|
||||||
|
if (VALUE_FLAGS.has(arg)) {
|
||||||
|
if (seenValueFlags.has(arg)) {
|
||||||
|
fail(`${arg} was provided more than once`);
|
||||||
|
}
|
||||||
|
seenValueFlags.add(arg);
|
||||||
|
}
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case "--iters":
|
case "--iters":
|
||||||
opts.iters = parsePositiveInt(next, arg);
|
opts.iters = parsePositiveInt(next, arg);
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,24 @@ describe("scripts/embedded-run-abort-leak", () => {
|
||||||
expect(readdirSync(looseThresholdProbe.snapDir)).toEqual([]);
|
expect(readdirSync(looseThresholdProbe.snapDir)).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rejects duplicate thresholds before writing heap snapshots", () => {
|
||||||
|
const snapDir = makeTempRoot();
|
||||||
|
const result = runHarness([
|
||||||
|
"--snap-dir",
|
||||||
|
snapDir,
|
||||||
|
"--iters",
|
||||||
|
"1",
|
||||||
|
"--iters",
|
||||||
|
"2",
|
||||||
|
"--quiet",
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(result.status).toBe(2);
|
||||||
|
expect(result.stdout).toBe("");
|
||||||
|
expect(result.stderr).toContain("error: --iters was provided more than once");
|
||||||
|
expect(readdirSync(snapDir)).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
it("rejects missing snapshot directories before writing heap snapshots", () => {
|
it("rejects missing snapshot directories before writing heap snapshots", () => {
|
||||||
const result = runHarness(["--snap-dir", "--quiet", "--iters", "1", "--batches", "1"]);
|
const result = runHarness(["--snap-dir", "--quiet", "--iters", "1", "--batches", "1"]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue