Skip to content

Commit d01c290

Browse files
committed
test(sdk): assert surface budget growth guard
1 parent d3cfef3 commit d01c290

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

test/scripts/plugin-sdk-surface-report.test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Plugin Sdk Surface Report tests cover plugin sdk surface report script behavior.
22
import { spawnSync } from "node:child_process";
3-
import { readFileSync } from "node:fs";
43
import { describe, expect, it } from "vitest";
54

65
function runSurfaceReport(env: Record<string, string>) {
@@ -14,14 +13,16 @@ function runSurfaceReport(env: Record<string, string>) {
1413
});
1514
}
1615

17-
function readDefaultPublicFunctionExportBudget() {
18-
const source = readFileSync("scripts/plugin-sdk-surface-report.mjs", "utf8");
19-
const match =
20-
/publicFunctionExports:\s*readBudgetEnv\("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS",\s*(\d+)\)/u.exec(
21-
source,
22-
);
16+
function readCurrentPublicFunctionExportCount() {
17+
const result = runSurfaceReport({});
18+
expect(result.status).toBe(0);
19+
expect(result.stderr).toBe("");
20+
21+
const match = /public package SDK entrypoints:[\s\S]*?\n callable exports: (\d+)/u.exec(
22+
result.stdout,
23+
);
2324
if (match === null || match[1] === undefined) {
24-
throw new Error("failed to read default public function export budget");
25+
throw new Error("failed to read current public function export count");
2526
}
2627
return Number(match[1]);
2728
}
@@ -95,7 +96,7 @@ describe("plugin SDK surface report", () => {
9596
});
9697

9798
it("keeps generated package declarations out of source surface counts", () => {
98-
const budget = readDefaultPublicFunctionExportBudget();
99+
const budget = readCurrentPublicFunctionExportCount();
99100
const result = runSurfaceReport({
100101
OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS: String(budget - 1),
101102
});

0 commit comments

Comments
 (0)