mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
refactor(tooling): simplify plugin boundary checks (#122781)
This commit is contained in:
committed by
GitHub
parent
a9ee6618fe
commit
2c5f024145
@@ -1 +0,0 @@
|
||||
[]
|
||||
@@ -1,26 +1,38 @@
|
||||
// Plugin extension import boundary tests enforce plugin extension import rules.
|
||||
import { readFileSync } from "node:fs";
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { main } from "../scripts/check-plugin-extension-import-boundary.mts";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
collectRetiredWebSearchCorePathEntries,
|
||||
main,
|
||||
} from "../scripts/check-plugin-extension-import-boundary.mts";
|
||||
import { createCapturedIo } from "./helpers/captured-io.js";
|
||||
import { useAutoCleanupTempDirTracker } from "./helpers/temp-dir.js";
|
||||
|
||||
const repoRoot = process.cwd();
|
||||
const baselinePath = path.join(
|
||||
repoRoot,
|
||||
"test",
|
||||
"fixtures",
|
||||
"plugin-extension-import-boundary-inventory.json",
|
||||
);
|
||||
const baseline = JSON.parse(readFileSync(baselinePath, "utf8"));
|
||||
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
|
||||
|
||||
describe("plugin extension import boundary inventory", () => {
|
||||
it("script json output matches the baseline exactly", async () => {
|
||||
it("current tree has no plugin extension imports", async () => {
|
||||
const captured = createCapturedIo();
|
||||
const exitCode = await main(["--json"], captured.io);
|
||||
|
||||
expect(exitCode).toBe(0);
|
||||
expect(captured.readStderr()).toBe("");
|
||||
expect(JSON.parse(captured.readStdout())).toEqual(baseline);
|
||||
expect(JSON.parse(captured.readStdout())).toEqual([]);
|
||||
});
|
||||
|
||||
it("rejects retired core web-search ownership paths", () => {
|
||||
const root = tempDirs.make("openclaw-retired-web-search-");
|
||||
const relativeFile = "src/plugins/web-search-providers.mjs";
|
||||
const filePath = path.join(root, relativeFile);
|
||||
mkdirSync(path.dirname(filePath), { recursive: true });
|
||||
writeFileSync(filePath, "export {};\n", "utf8");
|
||||
|
||||
expect(collectRetiredWebSearchCorePathEntries(root)).toEqual([
|
||||
expect.objectContaining({
|
||||
file: relativeFile,
|
||||
kind: "retired-path",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// Web provider boundary tests enforce provider import boundaries.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { main as webFetchMain } from "../scripts/check-web-fetch-provider-boundaries.mts";
|
||||
import { main as webSearchMain } from "../scripts/check-web-search-provider-boundaries.mts";
|
||||
import { createCapturedIo } from "./helpers/captured-io.js";
|
||||
|
||||
const webFetchJsonOutputPromise = getJsonOutput(webFetchMain);
|
||||
const webSearchJsonOutputPromise = getJsonOutput(webSearchMain);
|
||||
|
||||
async function getJsonOutput(
|
||||
main: (argv: string[], io: ReturnType<typeof createCapturedIo>["io"]) => Promise<number>,
|
||||
@@ -27,12 +25,4 @@ describe("web provider boundaries", () => {
|
||||
expect(jsonOutput.stderr).toBe("");
|
||||
expect(jsonOutput.json).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it("runs the web search boundary script in JSON mode", async () => {
|
||||
const jsonOutput = await webSearchJsonOutputPromise;
|
||||
|
||||
expect(jsonOutput.exitCode).toBe(0);
|
||||
expect(jsonOutput.stderr).toBe("");
|
||||
expect(jsonOutput.json).toStrictEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user