From b40f0f33d747b65d79d5ede813352b0cd5564d99 Mon Sep 17 00:00:00 2001 From: Geronimo Date: Sat, 10 Oct 2026 14:29:59 +0530 Subject: [PATCH] fix: make concurrency test genuinely overlapping with continuous validity probes Each writer performs 30 write rounds to widen the race window. Drop the vacuous exitCode liveness assert and the swallowing mid-flight read; instead every wait-loop poll reads and validates the state, so torn reads fail loudly. --- tests/lib/install-state.test.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/lib/install-state.test.js b/tests/lib/install-state.test.js index 629bbce54..ebbc33d5a 100644 --- a/tests/lib/install-state.test.js +++ b/tests/lib/install-state.test.js @@ -434,9 +434,11 @@ function runTests() { const { spawn } = require('child_process'); const script = 'const fs = require("fs");' + 'const {readInstallState, writeInstallState} = require(process.env.REPO_ROOT + "/scripts/lib/install-state");' + + 'for (let round = 0; round < 30; round += 1) {' + 'const state = readInstallState(process.env.STATE_PATH);' + 'state.lastValidatedAt = process.env.MARKER;' + 'writeInstallState(process.env.STATE_PATH, state);' + + '}' + 'fs.writeFileSync(process.env.DONE_FILE, "ok");'; const children = markers.slice(1).map(marker => { const tag = marker.replace(/:/g, '-'); @@ -456,18 +458,10 @@ function runTests() { fs.closeSync(errFd); return { child, marker, doneFile, errFile }; }); - assert.ok( - children.some(entry => entry.child.exitCode === null), - 'expected writers to still be running right after launch' - ); - let midRead = null; - try { - midRead = readInstallState(statePath); - } catch (_error) { - midRead = null; - } - const deadline = Date.now() + 60000; + const deadline = Date.now() + 120000; for (;;) { + const snapshot = readInstallState(statePath); + assert.ok(markers.includes(snapshot.lastValidatedAt)); const pending = children.filter(entry => !fs.existsSync(entry.doneFile)); if (pending.length === 0) break; if (Date.now() > deadline) { @@ -481,9 +475,6 @@ function runTests() { for (const entry of children) { assert.strictEqual(fs.readFileSync(entry.errFile, 'utf8'), '', `writer ${entry.marker} failed`); } - if (midRead !== null) { - assert.ok(markers.includes(midRead.lastValidatedAt)); - } const final = readInstallState(statePath); assert.ok(markers.includes(final.lastValidatedAt)); assert.deepStrictEqual(listStagingFiles(testDir), []);