mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
test(ips): share report inspection fixtures (#16281)
This commit is contained in:
1 parent
400d282848
commit
7cc831fef9
1 file changed
+18
-37
@@ -24,15 +24,20 @@ const report = parseAppleIps(
|
||||
inspectAppleIpsInputSchema.parse({ path }),
|
||||
);
|
||||
|
||||
const inspectReport = (value: AppleIps, maximum?: number) =>
|
||||
new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(value)),
|
||||
}).inspect({
|
||||
path: report.artifact.path,
|
||||
...(maximum === undefined ? {} : { max_integer_text_bytes: maximum }),
|
||||
});
|
||||
|
||||
it.each([0, 5])(
|
||||
"rejects an unresolved faulting thread %s without its mismatch",
|
||||
async (index) => {
|
||||
const unresolved: AppleIps = { ...report, faulting_thread: index };
|
||||
const service = new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(unresolved)),
|
||||
});
|
||||
const result = await service.inspect({ path: report.artifact.path });
|
||||
const result = await inspectReport(unresolved);
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) expect(result.error._tag).toBe("AnalysisOutputError");
|
||||
},
|
||||
@@ -53,10 +58,7 @@ it.each(["body.faultingThread", "body.other"])(
|
||||
],
|
||||
},
|
||||
};
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(unresolved)),
|
||||
}).inspect({ path: report.artifact.path });
|
||||
const result = await inspectReport(unresolved);
|
||||
expect(result.ok).toBe(path === "body.faultingThread");
|
||||
},
|
||||
);
|
||||
@@ -77,10 +79,7 @@ it.each([
|
||||
async (classification) => {
|
||||
const malformed = structuredClone(report);
|
||||
Reflect.set(malformed, "classification", classification);
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(malformed)),
|
||||
}).inspect({ path: report.artifact.path });
|
||||
const result = await inspectReport(malformed);
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) expect(result.error._tag).toBe("AnalysisOutputError");
|
||||
},
|
||||
@@ -91,10 +90,7 @@ it.each(["288", "309 "])(
|
||||
async (bugType) => {
|
||||
const malformed = structuredClone(report);
|
||||
Reflect.set(malformed.metadata, "bug_type", bugType);
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(malformed)),
|
||||
}).inspect({ path: report.artifact.path });
|
||||
const result = await inspectReport(malformed);
|
||||
if (result.ok) throw new Error("Expected unsupported provider crash kind");
|
||||
expect(result.error._tag).toBe("AnalysisOutputError");
|
||||
},
|
||||
@@ -125,10 +121,7 @@ it("rejects a relative path and extra arguments before reading", () =>
|
||||
));
|
||||
|
||||
it("records the selected report as a file subject", async () => {
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(report)),
|
||||
}).inspect({ path: report.artifact.path });
|
||||
const result = await inspectReport(report);
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value).toMatchObject({
|
||||
confidence: "observed",
|
||||
@@ -144,10 +137,7 @@ it.each(["threads", "images"] as const)(
|
||||
...report,
|
||||
coverage: { ...report.coverage, [field]: 1 },
|
||||
};
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(inconsistent)),
|
||||
}).inspect({ path: report.artifact.path });
|
||||
const result = await inspectReport(inconsistent);
|
||||
expect(result.ok).toBe(false);
|
||||
if (result.ok)
|
||||
throw new Error("Expected contradictory provider output to fail");
|
||||
@@ -177,10 +167,7 @@ it.each([
|
||||
unlisted_keys: [],
|
||||
},
|
||||
};
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(repeated)),
|
||||
}).inspect({ path: report.artifact.path, max_integer_text_bytes: maximum });
|
||||
const result = await inspectReport(repeated, maximum);
|
||||
expect(result.ok).toBe(accepted);
|
||||
if (!result.ok) expect(result.error._tag).toBe("AnalysisOutputError");
|
||||
},
|
||||
@@ -220,10 +207,7 @@ it.each([
|
||||
],
|
||||
},
|
||||
};
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(partial)),
|
||||
}).inspect({ path: report.artifact.path, max_integer_text_bytes: maximum });
|
||||
const result = await inspectReport(partial, maximum);
|
||||
expect(result.ok).toBe(accepted);
|
||||
if (!result.ok) expect(result.error._tag).toBe("AnalysisOutputError");
|
||||
},
|
||||
@@ -265,10 +249,7 @@ it.each([
|
||||
],
|
||||
coverage: { ...report.coverage, threads: 1, frames: 1 },
|
||||
};
|
||||
const result = await new AppleIpsService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok(withOffset)),
|
||||
}).inspect({ path: report.artifact.path, max_integer_text_bytes: maximum });
|
||||
const result = await inspectReport(withOffset, maximum);
|
||||
expect(result.ok).toBe(accepted);
|
||||
if (!result.ok) expect(result.error._tag).toBe("AnalysisOutputError");
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user