Skip to content

Commit b561060

Browse files
committed
Annotations after failure, better test_regrtest coverage
1 parent 9b1ce48 commit b561060

2 files changed

Lines changed: 39 additions & 20 deletions

File tree

‎Lib/test/libregrtest/testresult.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ def addUnexpectedSuccess(self, test):
134134

135135
def printErrorList(self, flavour, errors):
136136
for test, err in errors:
137+
super().printErrorList(flavour, [(test, err)])
137138
if self.GITHUB_ANNOTATIONS:
138-
# Write the annotation just before the failure report, so
139+
# Write the annotation just after the failure report, so
139140
# that it links to the report in the job log
140141
self.stream.writeln(github_annotation(str(test), err,
141142
self._test_file(test)))
142-
super().printErrorList(flavour, [(test, err)])
143143

144144
@staticmethod
145145
def _test_file(test):

‎Lib/test/test_regrtest.py‎

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,25 +1772,44 @@ def path(name):
17721772
crash: f'### {crash} worker non-zero exit code',
17731773
}
17741774

1775-
# Only failures of the last run are annotated: with --rerun and -W,
1776-
# failures of the first run are reported, but not annotated
1777-
for args in (['-j2', '-W'], ['-j2', '--rerun'],
1778-
['-j2', '-W', '--rerun'], ['-j0', '-W']):
1779-
tests = list(test_files)
1780-
if '-j0' in args:
1781-
# A crash kills the main process
1782-
tests.remove(crash)
1783-
with self.subTest(args=args):
1775+
# Representative command lines of the CI jobs
1776+
command_lines = {
1777+
# "make ci", Windows, macOS, installed Python; the JIT jobs use
1778+
# the equivalent "-j0 --verbose2 --verbose3". Only failures of
1779+
# the re-run are annotated, not the reported first failures.
1780+
'fast-ci': ['--fast-ci', '-j2'],
1781+
# Sanitizers and Hypothesis: env changed is not a failure
1782+
'parallel': ['-j2', '-W'],
1783+
# iOS and WASI run tests in the main process: a crash kills it
1784+
'single-process': ['--fast-ci', '--single-process'],
1785+
# Profile task of PGO and BOLT builds: no annotations
1786+
'pgo': ['--pgo'],
1787+
}
1788+
for name, args in command_lines.items():
1789+
with self.subTest(name):
1790+
tests = list(test_files)
1791+
if '--single-process' in args or '--pgo' in args:
1792+
tests.remove(crash)
17841793
output, summary = self.run_tests_github(
1785-
'--fail-env-changed', *args, *tests,
1786-
exitcode=EXITCODE_BAD_TEST)
1787-
1788-
self.assertCountEqual(
1789-
self.parse_github_annotations(output),
1790-
[*test_cases,
1791-
*((name, path(name), None)
1792-
for name in (env_changed, crash) if name in tests)],
1793-
output)
1794+
*args, *tests, exitcode=EXITCODE_BAD_TEST)
1795+
1796+
annotations = []
1797+
if '--pgo' not in args:
1798+
annotations += test_cases
1799+
if '--fast-ci' in args:
1800+
annotations.append((env_changed, path(env_changed),
1801+
None))
1802+
if crash in tests:
1803+
annotations.append((crash, path(crash), None))
1804+
self.assertCountEqual(self.parse_github_annotations(output),
1805+
annotations, output)
1806+
# Each test case is annotated right after its failure report
1807+
for title, _, _ in annotations[:len(test_cases)]:
1808+
title = re.escape(title)
1809+
self.assertRegex(
1810+
output,
1811+
rf'(?m)^(?:ERROR|FAIL): {title}\n'
1812+
rf'(?:(?!={{70}}$).*\n)*?::error .*title={title}::')
17941813

17951814
# The job summary lists the failed tests in completion order
17961815
summary_lines = summary.splitlines()

0 commit comments

Comments
 (0)