test(stt): stabilize idle-timeout progress test against spawn latency

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>
This commit is contained in:
andrexibiza
2026-08-04 00:38:50 -05:00
committed by Teknium
parent b00ebf6210
commit a70ea873cf
+11 -4
View File
@@ -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):