From b5b7f0983884263a6878cf67de0fef65ae684a40 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Wed, 1 Jul 2026 12:58:43 -0300 Subject: [PATCH] test(compression): de-flake rtk_discover sample seeding seedSamples() persisted two byte-identical raw outputs. The raw-output filename is keyed on Date.now() (ms) + a content hash (rawOutput.ts), so two identical captures landing in the same millisecond collapse to one file (the 2nd write overwrites the 1st) -> sampleCount 1 instead of 2. Reproduced at ~25% (501/2000 trials), matching the intermittent Coverage Shard (5/8) failure on fast CI runners. Seed two DISTINCT captures so the store deterministically holds 2 samples regardless of timing (0/2000 collisions after the change). --- tests/unit/compression/rtk-mcp-tools.test.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/unit/compression/rtk-mcp-tools.test.ts b/tests/unit/compression/rtk-mcp-tools.test.ts index eda2e0ee86..aefba54d0b 100644 --- a/tests/unit/compression/rtk-mcp-tools.test.ts +++ b/tests/unit/compression/rtk-mcp-tools.test.ts @@ -27,8 +27,17 @@ const NOISE = [ function seedSamples() { // retention "always" forces a capture even on a successful (non-failure) output. + // The two captures MUST differ in content: the raw-output filename is keyed on + // Date.now() (ms) + a hash of the content (see rawOutput.ts), so two BYTE-IDENTICAL + // captures that land in the same millisecond collapse to the same filename — the 2nd + // write overwrites the 1st, leaving only 1 sample. That made this test ~25% flaky on + // fast CI runners ("expected 2, got 1"). Distinct content = 2 files regardless of + // timing; two real build runs never emit byte-identical output anyway. maybePersistRtkRawOutput(NOISE, { retention: "always", command: "gradle build" }); - maybePersistRtkRawOutput(NOISE, { retention: "always", command: "gradle build" }); + maybePersistRtkRawOutput(`${NOISE}\n> Task :app:test UP-TO-DATE`, { + retention: "always", + command: "gradle build", + }); } beforeEach(() => {