chore(artifacts): reconcile captured main and preserve iNES history

This commit is contained in:
morluto
2026-10-13 23:02:09 +08:00
234 changed files with 12182 additions and 1983 deletions
@@ -1,5 +1,6 @@
import type { BigIntStats, Stats } from "node:fs";
import type { FileHandle } from "node:fs/promises";
import { tmpdir } from "node:os";
import { afterEach, expect, it, vi } from "vitest";
import {
@@ -88,3 +89,36 @@ it("compares available nanosecond timestamps without rounding away source change
sameRegularFileState(before, { ...before, ctimeNs: before.ctimeNs + 1n }),
).toBe(false);
});
it.each([
["EACCES", -13, "keeps"],
["ENXIO", -6, "reclassifies"],
] as const)(
"%s from opening a non-regular path: admission %s the failure",
async (code, errno, outcome) => {
const failure = Object.assign(new Error(`open ${code}`), { code, errno });
mockOpen.mockRejectedValue(failure);
// The selected path itself is a directory that stat can still describe.
const cause = await openRegularFile(tmpdir(), { symlinks: "follow" }).catch(
(rejected: unknown) => rejected,
);
if (outcome === "keeps") expect(cause).toBe(failure);
else expect(cause).toBeInstanceOf(NonRegularFileReadError);
},
);
it("keeps cancellation that arrives during the non-regular metadata probe", async () => {
const controller = new AbortController();
const cancellation = new Error("cancelled during probe");
mockOpen.mockImplementation(async () => {
// The probe stats the path after this rejection; abort before it settles.
queueMicrotask(() => controller.abort(cancellation));
throw Object.assign(new Error("open ENXIO"), { code: "ENXIO", errno: -6 });
});
await expect(
openRegularFile(tmpdir(), {
symlinks: "follow",
signal: controller.signal,
}),
).rejects.toBe(cancellation);
});
+16
View File
@@ -36,6 +36,22 @@ const archiveWithOverlappingObjectRanges = (objectCount: number): Buffer => {
};
describe("NIBArchive decoder", () => {
it("keeps leading U+FEFF in length-prefixed keys and class names", () => {
const archive = encodeArchive({
classes: ["\uFEFFWidget"],
objects: [{ classIndex: 0, values: { count: 1, "\uFEFFcount": 2 } }],
});
expect(decodeNibArchive(archive).objects).toEqual([
{
id: 0,
class_name: "\uFEFFWidget",
values: { count: 1, "\uFEFFcount": 2 },
},
]);
const invalid = Buffer.from(archive);
invalid[invalid.indexOf(Buffer.from("\uFEFFcount"))] = 0xff;
expect(() => decodeNibArchive(invalid)).toThrow(/not valid UTF-8/u);
});
it("decodes bounded object, key, class, and reference tables", () => {
const archive = encodeArchive({
classes: ["NSView\0", "NSString\0"],