mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
fix(test): clean perf summary cli errors
This commit is contained in:
@@ -669,7 +669,7 @@ function isCliEntry() {
|
||||
if (isCliEntry()) {
|
||||
main().catch(
|
||||
/** @param {unknown} error */ (error) => {
|
||||
console.error(error instanceof Error ? error.stack : String(error));
|
||||
console.error(error instanceof Error ? error.message : String(error));
|
||||
process.exitCode = 1;
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
@@ -17,6 +18,18 @@ function writeJson(filePath: string, value: unknown) {
|
||||
fs.writeFileSync(filePath, JSON.stringify(value), "utf8");
|
||||
}
|
||||
|
||||
function runCli(...args: string[]) {
|
||||
return spawnSync(process.execPath, ["scripts/openclaw-performance-source-summary.mjs", ...args], {
|
||||
cwd: path.resolve("."),
|
||||
encoding: "utf8",
|
||||
});
|
||||
}
|
||||
|
||||
function expectNoNodeStack(stderr: string) {
|
||||
expect(stderr).not.toContain("Node.js");
|
||||
expect(stderr).not.toContain("\n at ");
|
||||
}
|
||||
|
||||
function writeSourceFixture(sourceDir: string) {
|
||||
writeJson(path.join(sourceDir, "gateway-cpu", "gateway-startup-bench.json"), {
|
||||
results: [
|
||||
@@ -126,6 +139,20 @@ describe("parseArgs", () => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("reports CLI argument errors without a Node stack trace", () => {
|
||||
const missingSource = runCli();
|
||||
expect(missingSource.status).toBe(1);
|
||||
expect(missingSource.stdout).toBe("");
|
||||
expect(missingSource.stderr.trim()).toBe("--source-dir is required");
|
||||
expectNoNodeStack(missingSource.stderr);
|
||||
|
||||
const unknownArg = runCli("--wat");
|
||||
expect(unknownArg.status).toBe(1);
|
||||
expect(unknownArg.stdout).toBe("");
|
||||
expect(unknownArg.stderr.trim()).toBe("Unknown argument: --wat");
|
||||
expectNoNodeStack(unknownArg.stderr);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildMarkdown", () => {
|
||||
|
||||
Reference in New Issue
Block a user