mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 02:00:44 +00:00
ci: parallelize additional boundary guards
This commit is contained in:
61
test/scripts/run-additional-boundary-checks.test.ts
Normal file
61
test/scripts/run-additional-boundary-checks.test.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
formatCommand,
|
||||
resolveConcurrency,
|
||||
runChecks,
|
||||
} from "../../scripts/run-additional-boundary-checks.mjs";
|
||||
|
||||
function createOutputBuffer() {
|
||||
const chunks: string[] = [];
|
||||
return {
|
||||
output: {
|
||||
write(chunk: string) {
|
||||
chunks.push(chunk);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
text: () => chunks.join(""),
|
||||
};
|
||||
}
|
||||
|
||||
describe("run-additional-boundary-checks", () => {
|
||||
it("normalizes concurrency input", () => {
|
||||
expect(resolveConcurrency("6")).toBe(6);
|
||||
expect(resolveConcurrency("0")).toBe(4);
|
||||
expect(resolveConcurrency("nope", 2)).toBe(2);
|
||||
});
|
||||
|
||||
it("formats command display text", () => {
|
||||
expect(formatCommand({ command: "pnpm", args: ["run", "lint:core"] })).toBe(
|
||||
"pnpm run lint:core",
|
||||
);
|
||||
});
|
||||
|
||||
it("buffers grouped output and reports aggregate failures", async () => {
|
||||
const buffer = createOutputBuffer();
|
||||
const failures = await runChecks(
|
||||
[
|
||||
{
|
||||
label: "passes",
|
||||
command: process.execPath,
|
||||
args: ["-e", "console.log('ok-out')"],
|
||||
},
|
||||
{
|
||||
label: "fails",
|
||||
command: process.execPath,
|
||||
args: ["-e", "console.error('bad-out'); process.exit(7)"],
|
||||
},
|
||||
],
|
||||
{ concurrency: 2, output: buffer.output },
|
||||
);
|
||||
|
||||
const text = buffer.text();
|
||||
expect(failures).toBe(1);
|
||||
expect(text).toContain("::group::passes");
|
||||
expect(text).toContain("ok-out");
|
||||
expect(text).toContain("[ok] passes");
|
||||
expect(text).toContain("::group::fails");
|
||||
expect(text).toContain("bad-out");
|
||||
expect(text).toContain("::error title=fails failed::fails failed (exit 7)");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user