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

View File

@ -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}`,
});

View File

@ -24,29 +24,6 @@ import {
} from "../../../src/domain/binaryTarget.fixture.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { readWithoutFifoWriter } from "../../fixtures/fifoInput.js";
it.skipIf(process.platform === "win32")(
"rejects a selected FIFO without waiting for a writer",
async () => {
const root = await createTestTempDirectory("rea-binary-target-fifo-");
const fifoPath = join(root, "input.bin");
await promisify(execFile)("mkfifo", [fifoPath]);
const outcome = await readWithoutFifoWriter(fifoPath, () =>
parseBinaryTarget(fifoPath),
);
expect(outcome.state).toBe("completed");
if (outcome.state !== "completed")
throw new Error("Binary target resolution waited for a FIFO writer");
expect(outcome.result).toMatchObject({
ok: false,
error: {
_tag: "BinaryTargetError",
reason: "target is not a regular file",
},
});
},
);
describe("binary target I/O: app plist permissions and decoding", () => {
it.each([

View File

@ -35,7 +35,10 @@ it.skipIf(process.platform === "win32")(
throw new Error("MCP open_binary waited for a FIFO writer");
expect(outcome.result.isError).toBe(true);
expect(parseMcpToolError(outcome.result)).toMatchObject({
error: { message: expect.stringContaining("not a regular file") },
error: {
code: "target_unavailable",
message: expect.stringContaining("not a regular file"),
},
});
} finally {
await Promise.allSettled([