Skip to content

Commit dd5bf31

Browse files
miss-islingtonvstinnerhugovk
authored
[3.12] gh-129363: Change regrtest sequential mode output (GH-129476) (#130406)
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 <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 6c4de32 commit dd5bf31

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

Lib/test/libregrtest/main.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,11 @@ def run_tests_sequentially(self, runtests):
380380
msg += " (timeout: %s)" % format_duration(runtests.timeout)
381381
self.log(msg)
382382

383-
previous_test = None
384383
tests_iter = runtests.iter_tests()
385384
for test_index, test_name in enumerate(tests_iter, 1):
386385
start_time = time.perf_counter()
387386

388-
text = test_name
389-
if previous_test:
390-
text = '%s -- %s' % (text, previous_test)
391-
self.logger.display_progress(test_index, text)
387+
self.logger.display_progress(test_index, test_name)
392388

393389
result = self.run_test(test_name, runtests, tracer)
394390

@@ -405,19 +401,14 @@ def run_tests_sequentially(self, runtests):
405401
except (KeyError, AttributeError):
406402
pass
407403

408-
if result.must_stop(self.fail_fast, self.fail_env_changed):
409-
break
410-
411-
previous_test = str(result)
404+
text = str(result)
412405
test_time = time.perf_counter() - start_time
413406
if test_time >= PROGRESS_MIN_TIME:
414-
previous_test = "%s in %s" % (previous_test, format_duration(test_time))
415-
elif result.state == State.PASSED:
416-
# be quiet: say nothing if the test passed shortly
417-
previous_test = None
407+
text = f"{text} in {format_duration(test_time)}"
408+
self.logger.display_progress(test_index, text)
418409

419-
if previous_test:
420-
print(previous_test)
410+
if result.must_stop(self.fail_fast, self.fail_env_changed):
411+
break
421412

422413
return tracer
423414

Lib/test/test_regrtest.py

+13-2
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
@@ -543,8 +554,8 @@ def check_line(self, output, pattern, full=False, regex=True):
543554
self.assertRegex(output, regex)
544555

545556
def parse_executed_tests(self, output):
546-
regex = (r'^%s\[ *[0-9]+(?:/ *[0-9]+)*\] (%s)'
547-
% (LOG_PREFIX, self.TESTNAME_REGEX))
557+
regex = (fr'^{LOG_PREFIX}\[ *[0-9]+(?:/ *[0-9]+)*\] '
558+
fr'({self.TESTNAME_REGEX}) {RESULT_REGEX}')
548559
parser = re.finditer(regex, output, re.MULTILINE)
549560
return list(match.group(1) for match in parser)
550561

0 commit comments

Comments
 (0)