gh-129363: Change regrtest sequential mode output (#129476)

First, write the test name without color. Then, write the test name
and the result with color. Each test is displayed twice.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Victor Stinner 2025-02-21 14:55:32 +01:00 committed by GitHub
parent c359fcd2f5
commit f1b81c408f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 17 deletions

View file

@ -399,15 +399,11 @@ class Regrtest:
msg += " (timeout: %s)" % format_duration(runtests.timeout)
self.log(msg)
previous_test = None
tests_iter = runtests.iter_tests()
for test_index, test_name in enumerate(tests_iter, 1):
start_time = time.perf_counter()
text = test_name
if previous_test:
text = '%s -- %s' % (text, previous_test)
self.logger.display_progress(test_index, text)
self.logger.display_progress(test_index, test_name)
result = self.run_test(test_name, runtests, tracer)
@ -424,19 +420,14 @@ class Regrtest:
except (KeyError, AttributeError):
pass
if result.must_stop(self.fail_fast, self.fail_env_changed):
break
previous_test = str(result)
text = str(result)
test_time = time.perf_counter() - start_time
if test_time >= PROGRESS_MIN_TIME:
previous_test = "%s in %s" % (previous_test, format_duration(test_time))
elif result.state == State.PASSED:
# be quiet: say nothing if the test passed shortly
previous_test = None
text = f"{text} in {format_duration(test_time)}"
self.logger.display_progress(test_index, text)
if previous_test:
print(previous_test)
if result.must_stop(self.fail_fast, self.fail_env_changed):
break
def get_state(self) -> str:
state = self.results.get_state(self.fail_env_changed)