From 1a90b0b2548066c05202568a1f4f770c3c045508 Mon Sep 17 00:00:00 2001 From: Germain Haugou Date: Wed, 11 Mar 2026 15:19:13 +0100 Subject: [PATCH] fix: Progress bar appearing between START/OK messages The Rich Live auto-refresh could race with log() calls from worker threads, causing the progress bar to appear in the middle of test output. Fix: - Disable auto-refresh, only refresh on events - Serialize all console output + bar updates under one lock - Combine test_finished + log into single atomic operation 136 tests passing. --- python/gvtest/live_display.py | 18 +++++++++++++----- python/gvtest/tests.py | 3 +-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/python/gvtest/live_display.py b/python/gvtest/live_display.py index da8b813..d614254 100644 --- a/python/gvtest/live_display.py +++ b/python/gvtest/live_display.py @@ -83,7 +83,7 @@ def start(self, total: int) -> None: self.live = Live( self._render(), console=self.console, - refresh_per_second=4, + auto_refresh=False, transient=False, ) self.live.start() @@ -105,7 +105,8 @@ def test_started( ) def test_finished( - self, test_id: int, status: str + self, test_id: int, status: str, + message: str | None = None ) -> None: if not self._started: return @@ -117,18 +118,25 @@ def test_finished( self.failed += 1 elif status in ('skipped', 'excluded'): self.skipped += 1 + if message is not None and self.live is not None: + self.live.console.print( + message, highlight=False + ) self._update() def log(self, message: str) -> None: """Print a message above the live display.""" if self.live is not None: - self.live.console.print( - message, highlight=False - ) + with self.lock: + self.live.console.print( + message, highlight=False + ) + self.live.refresh() def _update(self) -> None: if self.live is not None: self.live.update(self._render()) + self.live.refresh() def _render(self) -> Text: """Render the progress bar with colored segments.""" diff --git a/python/gvtest/tests.py b/python/gvtest/tests.py index ac3b18b..d847c76 100644 --- a/python/gvtest/tests.py +++ b/python/gvtest/tests.py @@ -252,9 +252,8 @@ def print_end_message(self) -> None: ) elif self.runner.live_display is not None: self.runner.live_display.test_finished( - id(self), self.status + id(self), self.status, msg ) - self.runner.live_display.log(msg) else: _console.print(msg)