mirror of
https://github.com/python/cpython.git
synced 2025-11-03 11:23:31 +00:00
gh-109162: libregrtest: fix Logger (#109246)
* Pass results, quiet and pgo to Logger constructor. * Move display_progress() method from Regrtest to Logger. * No longer pass Regrtest to RunWorkers, but logger and results.
This commit is contained in:
parent
1ec45378e9
commit
0b6b05391b
3 changed files with 38 additions and 30 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import time
|
||||
|
||||
from test.libregrtest.results import TestResults
|
||||
from test.libregrtest.runtests import RunTests
|
||||
from test.libregrtest.utils import print_warning, MS_WINDOWS
|
||||
|
||||
|
|
@ -9,11 +10,14 @@ if MS_WINDOWS:
|
|||
|
||||
|
||||
class Logger:
|
||||
def __init__(self):
|
||||
def __init__(self, results: TestResults, quiet: bool, pgo: bool):
|
||||
self.start_time = time.perf_counter()
|
||||
self.test_count_text = ''
|
||||
self.test_count_width = 3
|
||||
self.win_load_tracker = None
|
||||
self._results: TestResults = results
|
||||
self._quiet: bool = quiet
|
||||
self._pgo: bool = pgo
|
||||
|
||||
def log(self, line: str = '') -> None:
|
||||
empty = not line
|
||||
|
|
@ -43,6 +47,18 @@ class Logger:
|
|||
return self.win_load_tracker.getloadavg()
|
||||
return None
|
||||
|
||||
def display_progress(self, test_index: int, text: str) -> None:
|
||||
if self._quiet:
|
||||
return
|
||||
results = self._results
|
||||
|
||||
# "[ 51/405/1] test_tcl passed"
|
||||
line = f"{test_index:{self.test_count_width}}{self.test_count_text}"
|
||||
fails = len(results.bad) + len(results.env_changed)
|
||||
if fails and not self._pgo:
|
||||
line = f"{line}/{fails}"
|
||||
self.log(f"[{line}] {text}")
|
||||
|
||||
def set_tests(self, runtests: RunTests) -> None:
|
||||
if runtests.forever:
|
||||
self.test_count_text = ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue