mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(test): guard model resolution profiler args
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Issue 78851 profiler CLI tests cover argument handling before work starts.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
function runProfiler(...args: string[]) {
|
||||
return spawnSync(
|
||||
process.execPath,
|
||||
["--import", "tsx", "scripts/perf/issue-78851-model-resolution.ts", ...args],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
describe("issue 78851 model resolution profiler CLI", () => {
|
||||
it("prints help without starting the profiler", () => {
|
||||
const result = runProfiler("--help");
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout).toContain("OpenClaw issue #78851 model-resolution profiler");
|
||||
expect(result.stdout).toContain(
|
||||
"node --import tsx scripts/perf/issue-78851-model-resolution.ts [options]",
|
||||
);
|
||||
expect(result.stderr).toBe("");
|
||||
});
|
||||
|
||||
it("rejects unknown arguments before starting the profiler", () => {
|
||||
const result = runProfiler("--wat");
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toBe("");
|
||||
expect(result.stderr.trim()).toBe("Unknown argument: --wat");
|
||||
});
|
||||
|
||||
it("rejects partial numeric arguments before starting the profiler", () => {
|
||||
const result = runProfiler("--providers", "48junk");
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toBe("");
|
||||
expect(result.stderr.trim()).toBe("--providers must be a positive integer");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user