test: prove retained facts and remove preinstall source greps

This commit is contained in:
morluto committed 2026-11-19 22:12:19 -05:00
1 parent 6bb2ad90ac
commit e1e24543e4
4 files changed
+46 -30

No files matched your search

@@ -460,9 +460,16 @@ it("reports truncated StringData as partial coverage with a failing offset", asy
expect(windowsShortcutSchema.safeParse(report).success).toBe(true);
});
it.each([12, 16, 20, 24, 28, 32])(
it.each([
[12, "truncated"],
[16, "malformed_structure"],
[20, "truncated"],
[24, "malformed_structure"],
[28, "malformed_structure"],
[32, "malformed_structure"],
] as const)(
"points an out-of-range LinkInfo offset at its field at byte %i",
async (field) => {
async (field, code) => {
const bytes = windowsShortcutBytes({
idList: null,
linkInfo: {
@@ -474,6 +481,9 @@ it.each([12, 16, 20, 24, 28, 32])(
const report = await parse(bytes);
expect(report.coverage.status).toBe("partial");
expect(report.coverage.failing_offset).toBe(76 + field);
expect(report.issues).toContainEqual(
expect.objectContaining({ code, offset: 76 + field }),
);
expect(report.issues.every((issue) => issue.offset < bytes.length)).toBe(
true,
);
@@ -66,7 +66,38 @@ it("discards unverified desktop byte facts when the admitted root changes during
const original = join(root, "original");
const moved = join(root, "moved");
await mkdir(original);
await writeFile(join(original, "sample.exe"), Buffer.from("MZ"));
const library = "GameAssembly.dll";
await writeFile(
join(original, library),
Buffer.from([0x7f, 0x45, 0x4c, 0x46]),
);
const pathFact = {
kind: "il2cpp-library-convention",
offset: null,
value: library,
};
const baseline = new DesktopApplicationService(
new DesktopApplicationReader(),
);
try {
const inspected = await baseline.inspect({ path: original });
if (!inspected.ok) throw inspected.error;
const report = desktopApplicationSchema.parse(
inspected.value.normalized_result,
);
expect(report.files).toMatchObject([
{
path: library,
ranges: [{ offset: 0, bytes: 4 }],
facts: [
pathFact,
{ kind: "native-image-header", offset: 0, value: { format: "elf" } },
],
},
]);
} finally {
await baseline.close();
}
const service = new DesktopApplicationService(
new DesktopApplicationReader((path) => {
const reader = new DirectoryArtifactReader(path);
@@ -98,13 +129,11 @@ it("discards unverified desktop byte facts when the admitted root changes during
expect(report.root.path).toBe(original);
expect(report.files).toHaveLength(1);
expect(report.files[0]).toMatchObject({
path: "sample.exe",
path: library,
read_status: "unavailable",
ranges: [],
facts: [pathFact],
});
expect(report.files[0]?.facts.every((fact) => fact.offset === null)).toBe(
true,
);
expect(report.coverage.status).toBe("partial");
} finally {
await service.close();
@@ -1,4 +1,3 @@
import { readFile } from "node:fs/promises";
import { expect, it } from "vitest";
import {
isComparisonOrCountFile,
@@ -229,17 +228,6 @@ it("exempts a default whose operand starts on an earlier line", () => {
).toBe(1);
});
it("loads without installed dependencies, as CI runs it before npm ci", async () => {
const source = await readFile(
new URL(
"../../scripts/verify/optional-fact-default-guard.mjs",
import.meta.url,
),
"utf8",
);
expect(source).not.toMatch(/\bfrom\s+["'](?!node:|\.)/u);
});
it("selects comparison, coverage and count files only", () => {
expect(isComparisonOrCountFile("src/domain/artifactComparison.ts")).toBe(
true,
-11
View File
@@ -1,4 +1,3 @@
import { readFile } from "node:fs/promises";
import { expect, it } from "vitest";
import { unmarkedMatchCount } from "../../scripts/verify/reason-marker.mjs";
@@ -97,13 +96,3 @@ it("reads a regular expression after a control head as a statement", () => {
0,
);
});
it("loads without installed dependencies, as CI runs it before npm ci", async () => {
for (const module of ["reason-marker.mjs", "source-tokens.mjs"]) {
const source = await readFile(
new URL(`../../scripts/verify/${module}`, import.meta.url),
"utf8",
);
expect(source).not.toMatch(/\bfrom\s+["'](?!node:|\.)/u);
}
});