From a70ea873cffd4f0537a7e67cf501b069bed2feb7 Mon Sep 17 00:00:00 2001 From: andrexibiza <84248988+andrexibiza@users.noreply.github.com> Date: Tue, 4 Aug 2026 00:38:50 -0500 Subject: [PATCH] test(stt): stabilize idle-timeout progress test against spawn latency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stderr-progress idle-timeout test used a 0.1s idle window with 0.04s ticks — shorter than Windows process spawn, so the first chunk could never arrive in time (deterministic failure on Windows, flake under Linux CI load). Verified failing identically on pristine main before the change. Fix: emit the first tick immediately, tick every 50ms for ~400ms total, 250ms idle window (5x tick period). The pass still depends on the progress extension while tolerating real spawn/scheduling latency. Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com> --- tests/tools/test_transcription_tools.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py index e9d7b50b32..3efd0b7efe 100644 --- a/tests/tools/test_transcription_tools.py +++ b/tests/tools/test_transcription_tools.py @@ -1203,12 +1203,19 @@ class TestRunCommandSttIdleTimeout: from tools.transcription_command import _run_command_stt script = tmp_path / "progress_then_exit.py" + # First tick is emitted immediately and the rest every 50ms — the + # total runtime (~400ms) exceeds the 250ms idle window, so passing + # depends on the progress extension. The immediate first tick also + # keeps the test honest on Windows, where process spawn alone can + # exceed a tiny idle window and previously raised TimeoutExpired + # before the first chunk was ever read (with all child output intact). script.write_text( "\n".join([ "import sys, time", - "for idx in range(4):", + "print('tick 0', file=sys.stderr, flush=True)", + "for idx in range(1, 9):", + " time.sleep(0.05)", " print(f'tick {idx}', file=sys.stderr, flush=True)", - " time.sleep(0.04)", "print('done', flush=True)", ]), encoding="utf-8", @@ -1216,11 +1223,11 @@ class TestRunCommandSttIdleTimeout: result = _run_command_stt( self._shell_command(sys.executable, "-u", str(script)), - timeout=0.1, + timeout=0.25, ) assert result.returncode == 0 - assert "tick 3" in result.stderr + assert "tick 8" in result.stderr assert "done" in result.stdout def test_silent_stall_still_times_out(self, tmp_path):