Skip to content

Commit 3047930

Browse files
betegonclaude
andcommitted
fix(test): replace Bun.sleep with utimes in project-root-cache mtime test
Same flakiness as dsn-cache: 10ms sleep is unreliable on Linux CI with 1-second filesystem mtime resolution. Use utimes() to set an explicit future mtime instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c4113ab commit 3047930

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

test/lib/db/project-root-cache.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ describe("getCachedProjectRoot", () => {
5454
const before = await getCachedProjectRoot(testProjectDir);
5555
expect(before).toBeDefined();
5656

57-
// Wait a moment and add a new file to change directory mtime
58-
await Bun.sleep(10);
57+
// Add a new file and explicitly bump dir mtime to guarantee a change
58+
// (don't rely on sleep — mtime resolution on Linux CI can be coarser than the delay)
59+
const { stat: statDir, utimes } = await import("node:fs/promises");
60+
const dirStats = await statDir(testProjectDir);
61+
const cachedMtime = Math.floor(dirStats.mtimeMs);
5962
writeFileSync(join(testProjectDir, "new-file.txt"), "test");
63+
const futureMtime = new Date(cachedMtime + 5000);
64+
await utimes(testProjectDir, futureMtime, futureMtime);
6065

6166
// Cache should be invalidated
6267
const after = await getCachedProjectRoot(testProjectDir);

0 commit comments

Comments
 (0)