mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-30 19:13:33 +00:00
fix(test): guard dev smoke cli args
This commit is contained in:
@@ -216,7 +216,46 @@ function runScript(url: string, extraArgs: readonly string[] = []): Promise<Scri
|
||||
});
|
||||
}
|
||||
|
||||
function runScriptRaw(args: readonly string[]): Promise<ScriptResult> {
|
||||
return new Promise((resolve) => {
|
||||
const child = spawn(
|
||||
process.execPath,
|
||||
["--import", "tsx", "scripts/dev/ios-node-e2e.ts", ...args],
|
||||
{
|
||||
stdio: "pipe",
|
||||
},
|
||||
);
|
||||
const stdout = createBoundedChildOutput();
|
||||
const stderr = createBoundedChildOutput();
|
||||
child.stdout.on("data", (chunk) => {
|
||||
stdout.append(chunk);
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
stderr.append(chunk);
|
||||
});
|
||||
child.on("close", (status, signal) => {
|
||||
resolve({ status, signal, stdout: stdout.text(), stderr: stderr.text(), timedOut: false });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
describe("ios-node-e2e", () => {
|
||||
it("prints CLI help without connecting", async () => {
|
||||
const result = await runScriptRaw(["--help"]);
|
||||
|
||||
expect(result).toMatchObject({ signal: null, status: 0, timedOut: false });
|
||||
expect(result.stdout).toContain("Usage: bun scripts/dev/ios-node-e2e.ts");
|
||||
expect(result.stderr).toBe("");
|
||||
});
|
||||
|
||||
it("rejects unknown CLI args before connecting", async () => {
|
||||
const result = await runScript("ws://127.0.0.1:9", ["--wat"]);
|
||||
|
||||
expect(result).toMatchObject({ signal: null, status: 1, timedOut: false });
|
||||
expect(result.stderr.trim()).toBe("Unknown argument: --wat");
|
||||
expect(result.stdout).toBe("");
|
||||
});
|
||||
|
||||
it("rejects malformed wait seconds before connecting", async () => {
|
||||
const result = await runScript("ws://127.0.0.1:9", ["--wait-seconds", "1e3"]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user