test: add Crestodian QA lab setup scenario

This commit is contained in:
Peter Steinberger
2026-04-25 13:15:05 +01:00
parent c977643460
commit b26367e22f
6 changed files with 349 additions and 5 deletions

View File

@@ -103,6 +103,48 @@ describe("qa suite runtime agent process helpers", () => {
);
});
it("merges isolated env overrides into qa cli runs", async () => {
const child = createSpawnedProcess();
spawnMock.mockReturnValue(child);
const pending = runQaCli(
{
repoRoot: "/repo",
gateway: {
tempRoot: "/tmp/runtime",
runtimeEnv: { PATH: "/usr/bin", OPENCLAW_STATE_DIR: "/tmp/default-state" },
},
primaryModel: "openai/gpt-5.4",
alternateModel: "openai/gpt-5.4-mini",
providerMode: "mock-openai",
} as never,
["crestodian", "-m", "overview"],
{
env: {
OPENCLAW_STATE_DIR: "/tmp/isolated-state",
OPENCLAW_CONFIG_PATH: "/tmp/isolated-state/openclaw.json",
},
},
);
await waitForSpawnCount(1);
child.stdout.emit("data", Buffer.from("ok\n"));
child.emit("exit", 0);
await expect(pending).resolves.toBe("ok");
expect(spawnMock).toHaveBeenCalledWith(
"/usr/bin/node",
["/repo/dist/index.js", "crestodian", "-m", "overview"],
expect.objectContaining({
env: expect.objectContaining({
PATH: "/usr/bin",
OPENCLAW_STATE_DIR: "/tmp/isolated-state",
OPENCLAW_CONFIG_PATH: "/tmp/isolated-state/openclaw.json",
}),
}),
);
});
it("parses json qa cli output when requested", async () => {
const child = createSpawnedProcess();
spawnMock.mockReturnValue(child);

View File

@@ -73,7 +73,7 @@ async function runQaCli(
"gateway" | "repoRoot" | "primaryModel" | "alternateModel" | "providerMode"
>,
args: string[],
opts?: { timeoutMs?: number; json?: boolean },
opts?: { timeoutMs?: number; json?: boolean; env?: NodeJS.ProcessEnv },
) {
const stdout: Buffer[] = [];
const stderr: Buffer[] = [];
@@ -82,7 +82,10 @@ async function runQaCli(
await new Promise<void>((resolve, reject) => {
const child = spawn(nodeExecPath, [distEntryPath, ...args], {
cwd: env.gateway.tempRoot,
env: env.gateway.runtimeEnv,
env: {
...env.gateway.runtimeEnv,
...opts?.env,
},
stdio: ["ignore", "pipe", "pipe"],
});
const timeout = setTimeout(() => {