test(daemon): stabilize artifact-manifest reconcile mtime test on slow CI

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.
This commit is contained in:
李冠辰 2026-05-29 17:49:45 +08:00
parent 0c4b7e50be
commit 598e5fc69f

View file

@ -146,6 +146,14 @@ describe('run-end artifact manifest reconciliation (#2893)', () => {
// File written during the run
await writeProjectFile(projectsRoot, PROJECT_ID, 'new-output.html', '<p>new</p>');
// 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);