From dc585448323c17b567c403bb4600dfea1f7e8fa3 Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 1 Jun 2026 22:03:51 +0000 Subject: [PATCH] Address dev runner snapshot review feedback --- scripts/dev-runner-snapshot.mjs | 7 +++++- .../src/__tests__/dev-runner-snapshot.test.ts | 23 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/scripts/dev-runner-snapshot.mjs b/scripts/dev-runner-snapshot.mjs index a88eb997..7729a369 100644 --- a/scripts/dev-runner-snapshot.mjs +++ b/scripts/dev-runner-snapshot.mjs @@ -9,7 +9,12 @@ const defaultFileSystem = { }; export function isMissingPathError(error) { - return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT"; + return ( + typeof error === "object" && + error !== null && + "code" in error && + (error.code === "ENOENT" || error.code === "ENOTDIR") + ); } function toRelativePath(repoRoot, absolutePath) { diff --git a/server/src/__tests__/dev-runner-snapshot.test.ts b/server/src/__tests__/dev-runner-snapshot.test.ts index 828b4536..a54dd1b2 100644 --- a/server/src/__tests__/dev-runner-snapshot.test.ts +++ b/server/src/__tests__/dev-runner-snapshot.test.ts @@ -52,8 +52,9 @@ describe("dev-runner watched snapshot", () => { }, }; - expect(() => collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem })).not.toThrow(); - expect(collectWatchedSnapshot(createSnapshotOptions(root)).has("server/index.ts")).toBe(false); + const snapshot = collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem }); + + expect(snapshot.has("server/index.ts")).toBe(false); }); it("skips directories that disappear before they can be read", () => { @@ -74,15 +75,27 @@ describe("dev-runner watched snapshot", () => { statSync: fs.statSync, }; - expect(() => collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem })).not.toThrow(); - expect(collectWatchedSnapshot(createSnapshotOptions(root)).has("server/routes/health.ts")).toBe(false); + const snapshot = collectWatchedSnapshot({ ...createSnapshotOptions(root), fileSystem }); + + expect(snapshot.has("server/routes/health.ts")).toBe(false); }); - it("returns null for missing file signatures and reports deleted paths in diffs", () => { + it("returns null for missing file signatures and not-directory races", () => { const root = createTempRoot("paperclip-dev-runner-snapshot-diff-"); const missingPath = path.join(root, "server", "deleted.ts"); + const fileSystem = { + statSync() { + const error = new Error("not a directory") as NodeJS.ErrnoException; + error.code = "ENOTDIR"; + throw error; + }, + }; expect(readSignature(missingPath)).toBeNull(); + expect(readSignature(missingPath, fileSystem)).toBeNull(); + }); + + it("reports deleted paths in diffs", () => { expect(diffSnapshots(new Map([["server/deleted.ts", "1:1"]]), new Map())).toEqual(["server/deleted.ts"]); }); });