62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import path from "node:path";
|
|
import { spawn } from "node:child_process";
|
|
|
|
function runSmoke(payload: unknown) {
|
|
return new Promise<{
|
|
exitCode: number | null;
|
|
stdout: string;
|
|
stderr: string;
|
|
}>((resolve, reject) => {
|
|
const scriptPath = path.resolve("scripts/claw-runtime-smoke.mjs");
|
|
const child = spawn(process.execPath, [scriptPath], {
|
|
cwd: "/Users/kris/code/boss",
|
|
stdio: ["pipe", "pipe", "pipe"],
|
|
});
|
|
|
|
let stdout = "";
|
|
let stderr = "";
|
|
child.stdout.setEncoding("utf8");
|
|
child.stderr.setEncoding("utf8");
|
|
child.stdout.on("data", (chunk) => {
|
|
stdout += chunk;
|
|
});
|
|
child.stderr.on("data", (chunk) => {
|
|
stderr += chunk;
|
|
});
|
|
child.on("error", reject);
|
|
child.on("close", (exitCode) => {
|
|
resolve({ exitCode, stdout, stderr });
|
|
});
|
|
|
|
child.stdin.write(JSON.stringify(payload));
|
|
child.stdin.end();
|
|
});
|
|
}
|
|
|
|
test("claw runtime smoke script emits completed JSON for valid payload", async () => {
|
|
const result = await runSmoke({
|
|
requestKind: "master_agent_reply",
|
|
executionPrompt: "请回复链路正常",
|
|
model: "gpt-5.4",
|
|
reasoningEffort: "medium",
|
|
});
|
|
|
|
assert.equal(result.exitCode, 0);
|
|
assert.equal(result.stderr, "");
|
|
const parsed = JSON.parse(result.stdout);
|
|
assert.equal(parsed.status, "completed");
|
|
assert.match(parsed.output, /链路正常/);
|
|
assert.match(parsed.output, /gpt-5\.4/);
|
|
});
|
|
|
|
test("claw runtime smoke script emits failed JSON for invalid payload", async () => {
|
|
const result = await runSmoke("not-an-object");
|
|
|
|
assert.equal(result.exitCode, 0);
|
|
const parsed = JSON.parse(result.stdout);
|
|
assert.equal(parsed.status, "failed");
|
|
assert.match(parsed.error, /INVALID_CLAW_PAYLOAD/);
|
|
});
|