From 093d69350260d4446201c0a73592e451cfac043f Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 22 Jul 2026 11:22:03 -0700 Subject: [PATCH] test(progress): assert net-zero live-reporter delta, not absolute zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'only one process-level signal handler' test asserted __liveReporterCountForTest() === 0, which encodes 'no other test file in this bun process left a live reporter' — a shard-composition property, not this test's invariant. PR #3096's new test files reshuffled the LPT shard packing so a shardmate's live reporter now lands before progress.test.ts in CI shard 5, failing the test deterministically (both run attempts). Snapshot the count before the 50 lifecycles and assert the delta is zero, mirroring the installedBefore baseline the test already uses for the signal handler. Co-Authored-By: Claude Fable 5 --- test/progress.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/progress.test.ts b/test/progress.test.ts index 0e70e0d6f..bdaf6e798 100644 --- a/test/progress.test.ts +++ b/test/progress.test.ts @@ -216,17 +216,21 @@ describe('progress reporter', () => { }); test('only one process-level signal handler installed across many reporters', () => { - // Baseline: one handler already installed by prior tests in this file. + // Baseline: one handler already installed by prior tests in this file, and + // possibly live reporters from OTHER test files sharing this bun process + // (shard composition is not this test's invariant — assert the delta, not + // an absolute zero, or shard reshuffles make this fail spuriously). const installedBefore = __signalHandlerInstalledForTest(); + const liveBefore = __liveReporterCountForTest(); const { stream } = sink(false); for (let i = 0; i < 50; i++) { const p = createProgress({ mode: 'json', stream, minIntervalMs: 0, minItems: 1 }); p.start(`phase_${i}`, 1); p.finish(); } - // After 50 reporter lifecycles, still exactly one handler and zero leaked live entries. + // After 50 reporter lifecycles, still exactly one handler and zero NET leaked live entries. expect(__signalHandlerInstalledForTest()).toBe(installedBefore || true); - expect(__liveReporterCountForTest()).toBe(0); + expect(__liveReporterCountForTest()).toBe(liveBefore); }); test('startHeartbeat() fires heartbeats and stop() clears', async () => {