chore: reconcile iNES inventory with current main

This commit is contained in:
64579525
2026-10-13 09:36:35 +08:00
646 changed files with 49020 additions and 6280 deletions
@@ -619,23 +619,31 @@ describe("native DMG artifact reader", () => {
expect(calls).toContainEqual(["detach", "/dev/disk-fixture"]);
});
it("rejects non-zero verification results", async () => {
await expect(
createAttachedReader("/tmp/image.dmg", process.env, undefined, {
run: () =>
Promise.resolve({
stdout: "verify output",
stderr: "hdiutil: verify failed - image not recognized",
exitCode: 1,
}),
}),
).rejects.toMatchObject({
reason: "format",
message: expect.stringMatching(
/"arguments":\["verify","\/tmp\/image\.dmg"\].*"exitCode":1.*"stderr":"hdiutil: verify failed - image not recognized"/u,
),
});
});
// hdiutil localizes its diagnostics; en-GB and other English locales spell
// the refusal "recognised".
it.each(["recognized", "recognised"])(
"rejects non-zero verification results (image not %s)",
async (spelling) => {
await expect(
createAttachedReader("/tmp/image.dmg", process.env, undefined, {
run: () =>
Promise.resolve({
stdout: "verify output",
stderr: `hdiutil: verify failed - image not ${spelling}`,
exitCode: 1,
}),
}),
).rejects.toMatchObject({
reason: "format",
message: expect.stringMatching(
new RegExp(
`"arguments":\\["verify","/tmp/image\\.dmg"\\].*"exitCode":1.*"stderr":"hdiutil: verify failed - image not ${spelling}"`,
"u",
),
),
});
},
);
it("retains the root and reports unknown ownership when recovery discovery fails", async () => {
const mount = createMountFixture();
@@ -15,6 +15,7 @@ import {
import { dirname, join } from "node:path";
import { describe, expect, it } from "vitest";
import { NativeMacOSProvider } from "../../../../src/native/NativeMacOSProvider.js";
import { ArtifactResourceScope } from "../../../../src/artifacts/ArtifactResourceScope.js";
import {
withSignatureTarget,
verifySignatureTarget,
@@ -277,6 +278,7 @@ it("returns typed cancellation at binding entry and final verification", async (
await expect(
withSignatureTarget(
target,
new ArtifactResourceScope(),
async () => {
throw new Error("Cancelled acquisition must not invoke inspection");
},
@@ -286,14 +288,18 @@ it("returns typed cancellation at binding entry and final verification", async (
ok: false,
error: { _tag: "AnalysisCancelledError" },
});
await withSignatureTarget(target, async (binding) => {
const result = await verifySignatureTarget(target, binding, signal);
expect(result).toMatchObject({
ok: false,
error: { _tag: "AnalysisCancelledError" },
});
return result;
});
await withSignatureTarget(
target,
new ArtifactResourceScope(),
async (binding) => {
const result = await verifySignatureTarget(target, binding, signal);
expect(result).toMatchObject({
ok: false,
error: { _tag: "AnalysisCancelledError" },
});
return result;
},
);
});
it("preserves cancellation after a capture instead of classifying it as invalid output", async () => {
@@ -348,21 +354,31 @@ it("copies and hashes the same bytes across multiple snapshot chunks", async ()
const bytes = Buffer.alloc(128 * 1024 + 13, 42);
await writeFile(path, bytes);
const target = await nativeMachoTargetForFile(path);
await withSignatureTarget(target, async (binding) => {
expect(await readFile(binding.snapshotPath)).toEqual(bytes);
return verifySignatureTarget(target, binding);
});
await withSignatureTarget(
target,
new ArtifactResourceScope(),
async (binding) => {
expect(await readFile(binding.snapshotPath)).toEqual(bytes);
return verifySignatureTarget(target, binding);
},
);
});
it("cleans the private snapshot when inspection throws", async () => {
const { target } = await fixture();
let snapshotPath: string | undefined;
await expect(
withSignatureTarget(target, async (binding) => {
const result = await withSignatureTarget(
target,
new ArtifactResourceScope(),
async (binding) => {
snapshotPath = binding.snapshotPath;
throw new Error("Invalid parsed output");
}),
).rejects.toThrow("Invalid parsed output");
},
);
expect(result).toMatchObject({
ok: false,
error: { _tag: "AnalysisOutputError" },
});
if (snapshotPath === undefined) throw new Error("Expected snapshot");
await expect(lstat(dirname(snapshotPath))).rejects.toMatchObject({
code: "ENOENT",