Skip to content

Commit a67f809

Browse files
committed
fix(test): clean perf summary cli errors
1 parent 1f1c434 commit a67f809

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

scripts/openclaw-performance-source-summary.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ function isCliEntry() {
669669
if (isCliEntry()) {
670670
main().catch(
671671
/** @param {unknown} error */ (error) => {
672-
console.error(error instanceof Error ? error.stack : String(error));
672+
console.error(error instanceof Error ? error.message : String(error));
673673
process.exitCode = 1;
674674
},
675675
);

test/scripts/openclaw-performance-source-summary.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { spawnSync } from "node:child_process";
12
import fs from "node:fs";
23
import os from "node:os";
34
import path from "node:path";
@@ -17,6 +18,18 @@ function writeJson(filePath: string, value: unknown) {
1718
fs.writeFileSync(filePath, JSON.stringify(value), "utf8");
1819
}
1920

21+
function runCli(...args: string[]) {
22+
return spawnSync(process.execPath, ["scripts/openclaw-performance-source-summary.mjs", ...args], {
23+
cwd: path.resolve("."),
24+
encoding: "utf8",
25+
});
26+
}
27+
28+
function expectNoNodeStack(stderr: string) {
29+
expect(stderr).not.toContain("Node.js");
30+
expect(stderr).not.toContain("\n at ");
31+
}
32+
2033
function writeSourceFixture(sourceDir: string) {
2134
writeJson(path.join(sourceDir, "gateway-cpu", "gateway-startup-bench.json"), {
2235
results: [
@@ -126,6 +139,20 @@ describe("parseArgs", () => {
126139
);
127140
}
128141
});
142+
143+
it("reports CLI argument errors without a Node stack trace", () => {
144+
const missingSource = runCli();
145+
expect(missingSource.status).toBe(1);
146+
expect(missingSource.stdout).toBe("");
147+
expect(missingSource.stderr.trim()).toBe("--source-dir is required");
148+
expectNoNodeStack(missingSource.stderr);
149+
150+
const unknownArg = runCli("--wat");
151+
expect(unknownArg.status).toBe(1);
152+
expect(unknownArg.stdout).toBe("");
153+
expect(unknownArg.stderr.trim()).toBe("Unknown argument: --wat");
154+
expectNoNodeStack(unknownArg.stderr);
155+
});
129156
});
130157

131158
describe("buildMarkdown", () => {

0 commit comments

Comments
 (0)