From 598e5fc69fa951b93a61348dd37ad8bed141b581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=86=A0=E8=BE=B0?= Date: Fri, 29 May 2026 17:49:45 +0800 Subject: [PATCH] test(daemon): stabilize artifact-manifest reconcile mtime test on slow CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reconcile-on-run-end regression test compared `fs.statSync(...).mtimeMs` against a `Date.now()`-captured run-start timestamp using strict `<`, so if the new file's ms-truncated mtime tied with runStartTimeMs (or fell a hair below it on a runner with NTP jitter) the new-file branch was incorrectly skipped and the sidecar-existence assertion flaked. Force the new file's mtime to runStartTimeMs + 1 000 ms after the write so the ordering is deterministic regardless of system-clock vs filesystem precision differences. The old file already uses utimesSync for the same reason — this just makes both ends of the comparison explicit. --- .../tests/artifact-manifest-reconcile-on-run-end.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/daemon/tests/artifact-manifest-reconcile-on-run-end.test.ts b/apps/daemon/tests/artifact-manifest-reconcile-on-run-end.test.ts index 885f977c7..8477a58a3 100644 --- a/apps/daemon/tests/artifact-manifest-reconcile-on-run-end.test.ts +++ b/apps/daemon/tests/artifact-manifest-reconcile-on-run-end.test.ts @@ -146,6 +146,14 @@ describe('run-end artifact manifest reconciliation (#2893)', () => { // File written during the run await writeProjectFile(projectsRoot, PROJECT_ID, 'new-output.html', '

new

'); + // Force the new file's mtime strictly above runStartTimeMs. Without this, + // CI runners occasionally produce a file whose ms-truncated mtime equals + // (or, due to NTP jitter, falls a hair below) Date.now() captured a few + // microseconds earlier, which made the `<` mtime filter incorrectly skip + // the new file and the sidecar-existence assertion flaked. + const newPath = path.join(projectsRoot, PROJECT_ID, 'new-output.html'); + const futureTime = new Date(runStartTimeMs + 1_000); + fs.utimesSync(newPath, futureTime, futureTime); // Simulate the close-handler reconciliation with mtime filter const dir = path.join(projectsRoot, PROJECT_ID);