Files
openclaw/test/scripts/prepare-extension-package-boundary-artifacts.test.ts
2026-04-07 11:42:45 +01:00

44 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
createPrefixedOutputWriter,
runNodeStepsInParallel,
} from "../../scripts/prepare-extension-package-boundary-artifacts.mjs";
describe("prepare-extension-package-boundary-artifacts", () => {
it("prefixes each completed line and flushes the trailing partial line", () => {
let output = "";
const writer = createPrefixedOutputWriter("boundary", {
write(chunk: string) {
output += chunk;
},
});
writer.write("first line\nsecond");
writer.write(" line\nthird");
writer.flush();
expect(output).toBe("[boundary] first line\n[boundary] second line\n[boundary] third");
});
it("aborts sibling steps after the first failure", async () => {
const startedAt = Date.now();
await expect(
runNodeStepsInParallel([
{
label: "fail-fast",
args: ["--eval", "setTimeout(() => process.exit(2), 10)"],
timeoutMs: 5_000,
},
{
label: "slow-step",
args: ["--eval", "setTimeout(() => {}, 10_000)"],
timeoutMs: 5_000,
},
]),
).rejects.toThrow("fail-fast failed with exit code 2");
expect(Date.now() - startedAt).toBeLessThan(2_000);
});
});