mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:20:44 +00:00
perf: cache guard inventory checks
This commit is contained in:
@@ -16,14 +16,26 @@ function buildFixtureScope() {
|
||||
});
|
||||
}
|
||||
|
||||
const fixtureScope = buildFixtureScope();
|
||||
const publicSurfaceEnvelope = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: fixtureScope,
|
||||
report: "public-surface-usage",
|
||||
});
|
||||
const singleOwnerEnvelope = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: fixtureScope,
|
||||
report: "single-owner-shared",
|
||||
});
|
||||
const unusedEnvelope = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: fixtureScope,
|
||||
report: "unused-public-surface",
|
||||
});
|
||||
|
||||
describe("ts-topology", () => {
|
||||
it("collapses canonical symbols exported by multiple public subpaths", () => {
|
||||
const envelope = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: buildFixtureScope(),
|
||||
report: "public-surface-usage",
|
||||
});
|
||||
const sharedThing = envelope.records.find((record) =>
|
||||
const sharedThing = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("sharedThing"),
|
||||
);
|
||||
|
||||
@@ -38,16 +50,13 @@ describe("ts-topology", () => {
|
||||
});
|
||||
|
||||
it("counts renamed imports, namespace imports, type-only imports, and test-only consumers", () => {
|
||||
const envelope = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: buildFixtureScope(),
|
||||
report: "public-surface-usage",
|
||||
});
|
||||
const aliasedThing = envelope.records.find((record) =>
|
||||
const aliasedThing = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("aliasedThing"),
|
||||
);
|
||||
const sharedType = envelope.records.find((record) => record.exportNames.includes("SharedType"));
|
||||
const testOnlyThing = envelope.records.find((record) =>
|
||||
const sharedType = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("SharedType"),
|
||||
);
|
||||
const testOnlyThing = publicSurfaceEnvelope.records.find((record) =>
|
||||
record.exportNames.includes("testOnlyThing"),
|
||||
);
|
||||
|
||||
@@ -65,33 +74,17 @@ describe("ts-topology", () => {
|
||||
});
|
||||
|
||||
it("surfaces single-owner shared and unused reports correctly", () => {
|
||||
const singleOwner = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: buildFixtureScope(),
|
||||
report: "single-owner-shared",
|
||||
});
|
||||
const unused = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: buildFixtureScope(),
|
||||
report: "unused-public-surface",
|
||||
});
|
||||
|
||||
expect(singleOwner.records.map((record) => record.exportNames[0])).toContain(
|
||||
expect(singleOwnerEnvelope.records.map((record) => record.exportNames[0])).toContain(
|
||||
"singleOwnerHelper",
|
||||
);
|
||||
expect(singleOwner.records.map((record) => record.exportNames[0])).not.toContain("sharedThing");
|
||||
expect(unused.records.map((record) => record.exportNames[0])).toEqual(["unusedThing"]);
|
||||
expect(singleOwnerEnvelope.records.map((record) => record.exportNames[0])).not.toContain(
|
||||
"sharedThing",
|
||||
);
|
||||
expect(unusedEnvelope.records.map((record) => record.exportNames[0])).toEqual(["unusedThing"]);
|
||||
});
|
||||
|
||||
it("renders stable text summaries for the public-surface report", () => {
|
||||
const envelope = analyzeTopology({
|
||||
repoRoot,
|
||||
scope: buildFixtureScope(),
|
||||
report: "public-surface-usage",
|
||||
limit: 3,
|
||||
});
|
||||
|
||||
expect(renderTextReport(envelope, 3)).toMatchInlineSnapshot(`
|
||||
expect(renderTextReport({ ...publicSurfaceEnvelope, limit: 3 }, 3)).toMatchInlineSnapshot(`
|
||||
"Scope: custom
|
||||
Public exports analyzed: 6
|
||||
Production-used exports: 4
|
||||
|
||||
Reference in New Issue
Block a user