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 <trekkie@nomorestars.com>
This commit is contained in:
@@ -3236,16 +3236,25 @@ describe('evaluateUpdateCache lineage guard', () => {
|
|||||||
test('derivationIsNotMemoizedAcrossRenders', (t) => {
|
test('derivationIsNotMemoizedAcrossRenders', (t) => {
|
||||||
const dir = createTempGitProject('gsd-freshness-no-memo-');
|
const dir = createTempGitProject('gsd-freshness-no-memo-');
|
||||||
t.after(() => cleanup(dir));
|
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);
|
const stampA = commitN(dir, 5);
|
||||||
writeStateHead(dir, stampA);
|
writeStateHead(dir, stampA);
|
||||||
|
const first = read();
|
||||||
const first = readGsdState(dir, { stateFreshness: true });
|
|
||||||
assert.equal(first.freshness.commits_behind, 5);
|
assert.equal(first.freshness.commits_behind, 5);
|
||||||
|
|
||||||
const stampB = commitN(dir, 10);
|
const stampB = commitN(dir, 10);
|
||||||
writeStateHead(dir, stampB);
|
writeStateHead(dir, stampB);
|
||||||
|
const second = read();
|
||||||
const second = readGsdState(dir, { stateFreshness: true });
|
|
||||||
assert.equal(second.freshness.commits_behind, 10);
|
assert.equal(second.freshness.commits_behind, 10);
|
||||||
assert.notEqual(first.freshness.commits_behind, second.freshness.commits_behind);
|
assert.notEqual(first.freshness.commits_behind, second.freshness.commits_behind);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user