Skip to content

Commit 8ce48c8

Browse files
miss-islingtonvstinnerhugovk
authored
[3.13] gh-129363: Change regrtest sequential mode output (GH-129476) (#130405)
gh-129363: Change regrtest sequential mode output (GH-129476) First, write the test name without color. Then, write the test name and the result with color. Each test is displayed twice. (cherry picked from commit f1b81c4) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 2a978e1 commit 8ce48c8

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

Lib/test/libregrtest/main.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,11 @@ def run_tests_sequentially(self, runtests: RunTests) -> None:
387387
msg += " (timeout: %s)" % format_duration(runtests.timeout)
388388
self.log(msg)
389389

390-
previous_test = None
391390
tests_iter = runtests.iter_tests()
392391
for test_index, test_name in enumerate(tests_iter, 1):
393392
start_time = time.perf_counter()
394393

395-
text = test_name
396-
if previous_test:
397-
text = '%s -- %s' % (text, previous_test)
398-
self.logger.display_progress(test_index, text)
394+
self.logger.display_progress(test_index, test_name)
399395

400396
result = self.run_test(test_name, runtests, tracer)
401397

@@ -412,19 +408,14 @@ def run_tests_sequentially(self, runtests: RunTests) -> None:
412408
except (KeyError, AttributeError):
413409
pass
414410

415-
if result.must_stop(self.fail_fast, self.fail_env_changed):
416-
break
417-
418-
previous_test = str(result)
411+
text = str(result)
419412
test_time = time.perf_counter() - start_time
420413
if test_time >= PROGRESS_MIN_TIME:
421-
previous_test = "%s in %s" % (previous_test, format_duration(test_time))
422-
elif result.state == State.PASSED:
423-
# be quiet: say nothing if the test passed shortly
424-
previous_test = None
414+
text = f"{text} in {format_duration(test_time)}"
415+
self.logger.display_progress(test_index, text)
425416

426-
if previous_test:
427-
print(previous_test)
417+
if result.must_stop(self.fail_fast, self.fail_env_changed):
418+
break
428419

429420
def get_state(self) -> str:
430421
state = self.results.get_state(self.fail_env_changed)

Lib/test/test_regrtest.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@
3939
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
4040
ROOT_DIR = os.path.abspath(os.path.normpath(ROOT_DIR))
4141
LOG_PREFIX = r'[0-9]+:[0-9]+:[0-9]+ (?:load avg: [0-9]+\.[0-9]{2} )?'
42+
RESULT_REGEX = (
43+
'passed',
44+
'failed',
45+
'skipped',
46+
'interrupted',
47+
'env changed',
48+
'timed out',
49+
'ran no tests',
50+
'worker non-zero exit code',
51+
)
52+
RESULT_REGEX = fr'(?:{"|".join(RESULT_REGEX)})'
4253

4354
EXITCODE_BAD_TEST = 2
4455
EXITCODE_ENV_CHANGED = 3
@@ -552,8 +563,8 @@ def check_line(self, output, pattern, full=False, regex=True):
552563
self.assertRegex(output, regex)
553564

554565
def parse_executed_tests(self, output):
555-
regex = (r'^%s\[ *[0-9]+(?:/ *[0-9]+)*\] (%s)'
556-
% (LOG_PREFIX, self.TESTNAME_REGEX))
566+
regex = (fr'^{LOG_PREFIX}\[ *[0-9]+(?:/ *[0-9]+)*\] '
567+
fr'({self.TESTNAME_REGEX}) {RESULT_REGEX}')
557568
parser = re.finditer(regex, output, re.MULTILINE)
558569
return list(match.group(1) for match in parser)
559570

0 commit comments

Comments
 (0)