test(filesystem): bound FIFO regressions at consumers

This commit is contained in:
morluto
2026-10-10 04:23:03 +08:00
parent 5291bca108
commit 0bfb6e00ab
3 changed files with 15 additions and 25 deletions
@@ -8,6 +8,7 @@ import { expect, it } from "vitest";
import { inventoryArtifact } from "../../../src/artifacts/inventory/ArtifactInventory.js";
import { classifyAndHashRoot } from "../../../src/artifacts/inventory/classify.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { readWithoutFifoWriter } from "../../fixtures/fifoInput.js";
it.skipIf(process.platform === "win32")(
"rejects a FIFO artifact root without waiting for a writer",
@@ -16,7 +17,16 @@ it.skipIf(process.platform === "win32")(
const fifoPath = join(root, "input.asar");
await promisify(execFile)("mkfifo", [fifoPath]);
await expect(inventoryArtifact(fifoPath)).rejects.toMatchObject({
const outcome = await readWithoutFifoWriter(fifoPath, () =>
inventoryArtifact(fifoPath).then(
() => undefined,
(cause: unknown) => cause,
),
);
expect(outcome.state).toBe("completed");
if (outcome.state !== "completed")
throw new Error("Artifact inventory waited for a FIFO writer");
expect(outcome.result).toMatchObject({
reason: "format",
message: `Artifact root is not a regular file: ${fifoPath}`,
});