mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
refactor(plugins): print boundary success summary
This commit is contained in:
@@ -68,6 +68,23 @@ function formatFailureFooter(params = {}) {
|
||||
return footerLines.join("\n");
|
||||
}
|
||||
|
||||
export function formatBoundaryCheckSuccessSummary(params = {}) {
|
||||
const lines = ["extension package boundary check passed"];
|
||||
if (params.mode) {
|
||||
lines.push(`mode: ${params.mode}`);
|
||||
}
|
||||
if (Number.isInteger(params.compileCount)) {
|
||||
lines.push(`compiled plugins: ${params.compileCount}`);
|
||||
}
|
||||
if (Number.isInteger(params.canaryCount)) {
|
||||
lines.push(`canary plugins: ${params.canaryCount}`);
|
||||
}
|
||||
if (Number.isFinite(params.elapsedMs)) {
|
||||
lines.push(`elapsed: ${params.elapsedMs}ms`);
|
||||
}
|
||||
return `${lines.join("\n")}\n`;
|
||||
}
|
||||
|
||||
export function formatStepFailure(label, params = {}) {
|
||||
const stdoutSection = summarizeOutputSection("stdout", params.stdout ?? "");
|
||||
const stderrSection = summarizeOutputSection("stderr", params.stderr ?? "");
|
||||
@@ -486,6 +503,7 @@ function runCanaryCheck(extensionIds) {
|
||||
}
|
||||
|
||||
export async function main(argv = process.argv.slice(2)) {
|
||||
const startedAt = Date.now();
|
||||
const mode = parseMode(argv);
|
||||
const optInExtensionIds = collectOptInExtensionIds();
|
||||
const canaryExtensionIds = collectCanaryExtensionIds(optInExtensionIds);
|
||||
@@ -502,6 +520,14 @@ export async function main(argv = process.argv.slice(2)) {
|
||||
if (shouldRunCanary) {
|
||||
runCanaryCheck(canaryExtensionIds);
|
||||
}
|
||||
process.stdout.write(
|
||||
formatBoundaryCheckSuccessSummary({
|
||||
mode,
|
||||
compileCount: mode === "canary" ? 0 : optInExtensionIds.length,
|
||||
canaryCount: shouldRunCanary ? canaryExtensionIds.length : 0,
|
||||
elapsedMs: Date.now() - startedAt,
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
releaseBoundaryLock?.();
|
||||
teardownCanaryCleanup?.();
|
||||
|
||||
@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
acquireBoundaryCheckLock,
|
||||
cleanupCanaryArtifactsForExtensions,
|
||||
formatBoundaryCheckSuccessSummary,
|
||||
formatStepFailure,
|
||||
installCanaryArtifactCleanup,
|
||||
resolveBoundaryCheckLockPath,
|
||||
@@ -133,6 +134,26 @@ describe("check-extension-package-tsc-boundary", () => {
|
||||
expect(message).toContain("demo-plugin timed out after 5000ms");
|
||||
});
|
||||
|
||||
it("formats a success summary with counts and elapsed time", () => {
|
||||
expect(
|
||||
formatBoundaryCheckSuccessSummary({
|
||||
mode: "all",
|
||||
compileCount: 97,
|
||||
canaryCount: 12,
|
||||
elapsedMs: 54_321,
|
||||
}),
|
||||
).toBe(
|
||||
[
|
||||
"extension package boundary check passed",
|
||||
"mode: all",
|
||||
"compiled plugins: 97",
|
||||
"canary plugins: 12",
|
||||
"elapsed: 54321ms",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps full failure output on the thrown error for canary detection", async () => {
|
||||
await expect(
|
||||
runNodeStepAsync(
|
||||
|
||||
Reference in New Issue
Block a user