From 3d2cb1fb017d5463f502fe9d1b434b9741ce897f Mon Sep 17 00:00:00 2001 From: 0xdhx Date: Sun, 20 Sep 2026 00:19:07 -0500 Subject: [PATCH] test(#4850): read freshness under the fixture git timeout in derivationIsNotMemoizedAcrossRenders (#4870) The row asserts that deriveStateFreshness is not memoized across renders, and it did so through the hook's real git spawn bounded by the 1500 ms production timeout. On a loaded Windows runner the second spawn can exceed that bound, and readStateHeadCommits returns its designed null, which the exact-count assertion reads as a failure (null !== 10). Wrap the two freshness reads in the block's existing withSpawnSpy, forwarding to the real execFileSync with the fixture-scoped GIT_FIXTURE_TIMEOUT_MS in place of the production bound. The spawn stays real, so a genuine memoization regression (second read returning 5) still fails the row. No production file changes; STATE_FRESHNESS_GIT_TIMEOUT_MS stays 1500. Closes #4850 Co-authored-by: Tom Boucher --- tests/gsd-statusline.test.cjs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/gsd-statusline.test.cjs b/tests/gsd-statusline.test.cjs index c604e95e3..f523ddd28 100644 --- a/tests/gsd-statusline.test.cjs +++ b/tests/gsd-statusline.test.cjs @@ -3236,16 +3236,25 @@ describe('evaluateUpdateCache lineage guard', () => { test('derivationIsNotMemoizedAcrossRenders', (t) => { const dir = createTempGitProject('gsd-freshness-no-memo-'); t.after(() => cleanup(dir)); + // This row asserts non-memoization, not the timeout degrade: keep the + // real git spawn, lift only the hook's 1500 ms production bound so + // runner load cannot turn its designed `null` into a red (#4850). + const realExec = childProcess.execFileSync; + const unbounded = (file, args, opts) => realExec(file, args, { ...opts, timeout: GIT_FIXTURE_TIMEOUT_MS }); + const read = () => { + let state; + withSpawnSpy(unbounded, () => { state = readGsdState(dir, { stateFreshness: true }); }); + return state; + }; + const stampA = commitN(dir, 5); writeStateHead(dir, stampA); - - const first = readGsdState(dir, { stateFreshness: true }); + const first = read(); assert.equal(first.freshness.commits_behind, 5); const stampB = commitN(dir, 10); writeStateHead(dir, stampB); - - const second = readGsdState(dir, { stateFreshness: true }); + const second = read(); assert.equal(second.freshness.commits_behind, 10); assert.notEqual(first.freshness.commits_behind, second.freshness.commits_behind); });