Skip to content

Commit aa7b28d

Browse files
authored
[3.14] gh-161430: Omit tests expected to be skipped in regrtest (#161616)
No longer list tests expected to be skipped in the final report. Strip also "test." prefix in TestResults to make the output shorter. (cherry picked from commit 3de6d3a) Add utils.cleanup_test_name() function. (cherry picked from commit d7684fb) (cherry picked from commit 48df125)
1 parent bc35f90 commit aa7b28d

7 files changed

Lines changed: 391 additions & 11 deletions

File tree

‎Lib/test/libregrtest/results.py‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
from .runtests import RunTests
77
from .result import State, TestResult, TestStats, Location
8+
from .skipped import expected_to_be_skipped
89
from .utils import (
910
StrPath, TestName, TestTuple, TestList, FilterDict,
10-
printlist, count, format_duration)
11+
printlist, count, format_duration, cleanup_test_name)
1112

1213
if TYPE_CHECKING:
1314
from xml.etree.ElementTree import Element
@@ -100,7 +101,7 @@ def get_exitcode(self, fail_env_changed: bool, fail_rerun: bool) -> int:
100101
return exitcode
101102

102103
def accumulate_result(self, result: TestResult, runtests: RunTests) -> None:
103-
test_name = result.test_name
104+
test_name = cleanup_test_name(result.test_name)
104105
rerun = runtests.rerun
105106
fail_env_changed = runtests.fail_env_changed
106107

@@ -207,7 +208,19 @@ def write_junit(self, filename: StrPath) -> None:
207208
for s in ET.tostringlist(root):
208209
f.write(s)
209210

211+
def split_expected_skip(self, tests):
212+
skipped = []
213+
expected = []
214+
for name in tests:
215+
if expected_to_be_skipped(name):
216+
expected.append(name)
217+
else:
218+
skipped.append(name)
219+
return (skipped, expected)
220+
210221
def display_result(self, tests: TestTuple, quiet: bool, print_slowest: bool) -> None:
222+
tests = tuple(cleanup_test_name(name) for name in tests)
223+
211224
ansi = get_colors()
212225
green = ansi.GREEN
213226
red = ansi.BOLD_RED
@@ -224,13 +237,20 @@ def display_result(self, tests: TestTuple, quiet: bool, print_slowest: bool) ->
224237
all_tests = []
225238
omitted = set(tests) - self.get_executed()
226239

240+
# Filter tests expected to be skipped
241+
skipped, expected_skip = self.split_expected_skip(self.skipped)
242+
if expected_skip:
243+
print()
244+
count_text = count(len(expected_skip), "test")
245+
print(f"{count_text} expected to be skipped (not listed)")
246+
227247
# less important
228248
all_tests.append(
229249
(sorted(omitted), "test", f"{yellow}{{}} omitted:{reset}")
230250
)
231251
if not quiet:
232252
all_tests.append(
233-
(self.skipped, "test", f"{yellow}{{}} skipped:{reset}")
253+
(skipped, "test", f"{yellow}{{}} skipped:{reset}")
234254
)
235255
all_tests.append(
236256
(

0 commit comments

Comments
 (0)