mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 11:38:12 +00:00
fix(test): require vitest profile output dir
This commit is contained in:
@@ -10,6 +10,14 @@ import { createPnpmRunnerSpawnSpec } from "./pnpm-runner.mjs";
|
||||
/**
|
||||
* Parses Vitest profiler mode, output directory, and forwarded Vitest args.
|
||||
*/
|
||||
function readOutputDirValue(argv, index) {
|
||||
const value = argv[index + 1];
|
||||
if (value === undefined || value === "" || value.startsWith("--")) {
|
||||
throw new Error("Expected --output-dir <dir>.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function parseArgs(argv) {
|
||||
const args = {
|
||||
mode: "",
|
||||
@@ -28,7 +36,7 @@ export function parseArgs(argv) {
|
||||
break;
|
||||
}
|
||||
if (arg === "--output-dir") {
|
||||
args.outputDir = argv[i + 1] ?? "";
|
||||
args.outputDir = readOutputDirValue(argv, i);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,13 @@ describe("scripts/run-vitest-profile", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects missing profile output directories", () => {
|
||||
expect(() => parseArgs(["runner", "--output-dir"])).toThrow("Expected --output-dir <dir>.");
|
||||
expect(() => parseArgs(["runner", "--output-dir", "--", "--config", "custom.ts"])).toThrow(
|
||||
"Expected --output-dir <dir>.",
|
||||
);
|
||||
});
|
||||
|
||||
it("passes vitest args after a separator", () => {
|
||||
expect(parseArgs(["main", "--output-dir", "/tmp/out", "--", "--config", "custom.ts"])).toEqual({
|
||||
mode: "main",
|
||||
|
||||
Reference in New Issue
Block a user