gh-127718: Add colour to test.regrtest output (#127719)

This commit is contained in:
Hugo van Kemenade 2024-12-10 09:44:15 +02:00 committed by GitHub
parent 2233c303e4
commit 212448b162
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 168 additions and 53 deletions

View file

@ -6,6 +6,7 @@ import sys
import sysconfig
import time
import trace
from _colorize import get_colors # type: ignore[import-not-found]
from typing import NoReturn
from test.support import os_helper, MS_WINDOWS, flush_std_streams
@ -270,6 +271,9 @@ class Regrtest:
return runtests
def rerun_failed_tests(self, runtests: RunTests) -> None:
ansi = get_colors()
red, reset = ansi.BOLD_RED, ansi.RESET
if self.python_cmd:
# Temp patch for https://github.com/python/cpython/issues/94052
self.log(
@ -284,7 +288,10 @@ class Regrtest:
rerun_runtests = self._rerun_failed_tests(runtests)
if self.results.bad:
print(count(len(self.results.bad), 'test'), "failed again:")
print(
f"{red}{count(len(self.results.bad), 'test')} "
f"failed again:{reset}"
)
printlist(self.results.bad)
self.display_result(rerun_runtests)