Skip to content

Commit 041e577

Browse files
committed
Adjust and simplify a little
1 parent 6359876 commit 041e577

2 files changed

Lines changed: 11 additions & 24 deletions

File tree

‎Lib/test/libregrtest/main.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .logger import Logger
1717
from .pgo import setup_pgo_tests
1818
from .result import TestResult
19-
from .results import TestResults, EXITCODE_INTERRUPTED, annotate_github
19+
from .results import TestResults, EXITCODE_INTERRUPTED
2020
from .runtests import RunTests, HuntRefleak
2121
from .setup import setup_process, setup_test_dir
2222
from .single import run_single_test, PROGRESS_MIN_TIME
@@ -27,7 +27,7 @@
2727
printlist, get_temp_dir, get_work_dir, exit_timeout,
2828
display_header, cleanup_temp_dir, print_warning,
2929
is_cross_compiled, get_host_runner, display_title,
30-
get_process_memory_usage, EXIT_TIMEOUT)
30+
get_process_memory_usage, github_annotation, EXIT_TIMEOUT)
3131

3232

3333
class Regrtest:
@@ -491,10 +491,6 @@ def write_github_summary(self) -> None:
491491
return
492492
# Tests which failed in the last run (the re-run, if any)
493493
failed = self.results.rerun_results
494-
if not self.results.rerun:
495-
# Failed tests were not re-run (ex: --python): annotate them now
496-
for result in failed:
497-
annotate_github(result)
498494
cases = [(result.errors or []) + (result.failures or [])
499495
for result in failed]
500496
ncase = sum(map(len, cases))
@@ -511,7 +507,14 @@ def write(text: str) -> None:
511507
if result.env_changed_reasons:
512508
write("\n".join(f"- {reason}"
513509
for reason in result.env_changed_reasons))
510+
if not result_cases:
511+
message = "\n".join([str(result),
512+
*(result.env_changed_reasons or ())])
513+
github_annotation("error", result.test_name,
514+
decolor(message))
514515
for name, traceback in result_cases:
516+
github_annotation("error", f"{result.test_name}: {name}",
517+
decolor(traceback))
515518
# Expand short tracebacks when there are only a few
516519
is_open = ncase <= 5 and traceback.count("\n") < 30
517520
write(f"<details{' open' if is_open else ''}>"

‎Lib/test/libregrtest/results.py‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import os
21
import sys
32
import trace
4-
from _colorize import decolor, get_colors # type: ignore[import-not-found]
3+
from _colorize import get_colors # type: ignore[import-not-found]
54
lazy from xml.etree.ElementTree import Element
65

76
from .runtests import RunTests
87
from .result import State, TestResult, TestStats, Location
98
from .utils import (
109
StrPath, TestName, TestTuple, TestList, FilterDict,
11-
printlist, count, format_duration, github_annotation)
10+
printlist, count, format_duration)
1211

1312

1413
# Python uses exit code 1 when an exception is not caught
@@ -20,16 +19,6 @@
2019
EXITCODE_INTERRUPTED = 130 # 128 + signal.SIGINT=2
2120

2221

23-
def annotate_github(result: TestResult) -> None:
24-
cases = (result.errors or []) + (result.failures or [])
25-
for name, traceback in cases:
26-
github_annotation("error", f"{result.test_name}: {name}",
27-
decolor(traceback))
28-
if not cases:
29-
message = "\n".join([str(result), *(result.env_changed_reasons or ())])
30-
github_annotation("error", result.test_name, decolor(message))
31-
32-
3322
class TestResults:
3423
def __init__(self) -> None:
3524
self.bad: TestList = []
@@ -139,11 +128,6 @@ def accumulate_result(self, result: TestResult, runtests: RunTests) -> None:
139128
if result.state == State.WORKER_BUG:
140129
self.worker_bug = True
141130

142-
if (os.environ.get("GITHUB_STEP_SUMMARY") and rerun
143-
and result.is_failed(fail_env_changed)):
144-
# Only annotate tests which fail again when re-run
145-
annotate_github(result)
146-
147131
if result.has_meaningful_duration() and not rerun:
148132
if result.duration is None:
149133
raise ValueError("result.duration is None")

0 commit comments

Comments
 (0)