mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
test(managed): consolidate graph projection checks (#12979)
This commit is contained in:
1 parent
d184c208f3
commit
7cc9fa1166
1 file changed
+11
-34
@@ -126,17 +126,18 @@ describe("managed application graph MethodDef scope", () => {
|
||||
const full = memberGraph(bytes);
|
||||
expect(full.members.method_rows).toEqual({ offset: 0, count: 3, total: 3 });
|
||||
expect(full.result.coverage.status).toBe("complete-within-inputs");
|
||||
for (const options of [
|
||||
{ methodLimit: 0 },
|
||||
{ methodOffset: 1, methodLimit: 1 },
|
||||
{ methodOffset: 3 },
|
||||
]) {
|
||||
for (const [offset, count, options] of [
|
||||
[0, 0, { methodLimit: 0 }],
|
||||
[1, 1, { methodOffset: 1, methodLimit: 1 }],
|
||||
[3, 0, { methodOffset: 3 }],
|
||||
] as const) {
|
||||
const page = memberGraph(bytes, options);
|
||||
expect(page.members.coverage.state).toBe("complete");
|
||||
expect(page.result.summary.methods).toBe(page.members.method_rows!.count);
|
||||
expect(page.members.method_rows).toEqual({ offset, count, total: 3 });
|
||||
expect(page.result.summary.methods).toBe(count);
|
||||
expect(page.result.coverage.status).toBe("partial");
|
||||
expect(page.result.limitations).toContain(
|
||||
`Managed member Evidence examined MethodDef rows at offset ${page.members.method_rows!.offset} with count ${page.members.method_rows!.count} of 3 total rows; methods outside that interval and their relations are omitted, not absent.`,
|
||||
`Managed member Evidence examined MethodDef rows at offset ${offset} with count ${count} of 3 total rows; methods outside that interval and their relations are omitted, not absent.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -549,36 +550,16 @@ describe("managed application graph identity facts", () => {
|
||||
});
|
||||
|
||||
it("projects a module whose metadata name is empty without a label", () => {
|
||||
const bytes = buildManagedPeFixture({ ilBody: Buffer.from([0x06, 0x2a]) });
|
||||
const bytes = buildManagedPeFixture({ ilBody: tinyIl([0x2a]) });
|
||||
const control = inspectManagedMembersBytes(
|
||||
bytes,
|
||||
managedPeFixtureTarget(bytes, "/fixture/EmptyModuleName.dll"),
|
||||
managedPeFixtureTarget(bytes),
|
||||
);
|
||||
if (control.module === null) throw new Error("Expected a Module row");
|
||||
// Point the Module row's Name at the string heap's empty entry.
|
||||
bytes.writeUInt16LE(0, control.module.row_offset + 2);
|
||||
const binary = managedPeFixtureTarget(
|
||||
bytes,
|
||||
"/fixture/EmptyModuleName.dll",
|
||||
);
|
||||
const members = inspectManagedMembersBytes(bytes, binary);
|
||||
const { members, graph } = memberGraph(bytes);
|
||||
expect(members.module?.name).toBe("");
|
||||
const projected = projectManagedApplicationGraphEvidence({
|
||||
managed_members: createEvidence(binary, MANAGED_STATIC_PROVIDER, {
|
||||
operation: "inspect_managed_members",
|
||||
parameters: {},
|
||||
result: members,
|
||||
rawResult: null,
|
||||
limitations: members.limitations,
|
||||
locations: [{ kind: "artifact-path", path: binary.path }],
|
||||
}),
|
||||
});
|
||||
if (!projected.ok) throw projected.error;
|
||||
const graph = parseJavaScriptApplicationGraph(
|
||||
managedApplicationGraphResultSchema.parse(
|
||||
parseEvidence(projected.value).normalized_result,
|
||||
).graph,
|
||||
);
|
||||
expect(
|
||||
graph.nodes.find(({ kind }) => kind === "managed-module")
|
||||
?.observations[0],
|
||||
@@ -1203,12 +1184,8 @@ describe("managed call and field-access relations", () => {
|
||||
/inspected module.*omitted: 2 member-reference, 2 function-pointer.*3 recursive self-call/iu,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it("refuses graph Evidence without relation counters", () => {
|
||||
const { result } = memberGraph(relationsFixture());
|
||||
const { calls: _calls, ...summary } = result.summary;
|
||||
|
||||
expect(
|
||||
managedApplicationGraphResultSchema.safeParse({ ...result, summary })
|
||||
.error?.issues[0]?.path,
|
||||
|
||||
Reference in new issue
Block a user