Skip to content

Commit fa416c3

Browse files
Avoid comparing timestamps in fatal messages
1 parent 7ff1d5a commit fa416c3

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

tests/primer/primer_tool.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
PackageMessages = Dict[str, List[Dict[str, Union[str, int]]]]
2727

28+
GITHUB_CRASH_TEMPLATE_LOCATION = "/home/runner/.cache"
29+
CRASH_TEMPLATE_INTRO = "There is a pre-filled template"
30+
2831

2932
class Primer:
3033
"""Main class to handle priming of packages."""
@@ -128,6 +131,20 @@ def _handle_run_command(self) -> None:
128131
packages[package] = output
129132
print(f"Successfully primed {package}.")
130133

134+
astroid_errors = []
135+
other_fatal_msgs = []
136+
for msg in chain.from_iterable(packages.values()):
137+
if msg["type"] == "fatal":
138+
# Remove the crash template location if we're running on GitHub.
139+
# We were falsely getting "new" errors when the timestamp changed.
140+
assert isinstance(msg["message"], str)
141+
if GITHUB_CRASH_TEMPLATE_LOCATION in msg["message"]:
142+
msg["message"] = msg["message"].rsplit(CRASH_TEMPLATE_INTRO)[0]
143+
if msg["symbol"] == "astroid-error":
144+
astroid_errors.append(msg)
145+
else:
146+
other_fatal_msgs.append(msg)
147+
131148
with open(
132149
PRIMER_DIRECTORY
133150
/ f"output_{'.'.join(str(i) for i in sys.version_info[:3])}_{self.config.type}.txt",
@@ -141,13 +158,6 @@ def _handle_run_command(self) -> None:
141158
# This is to avoid introducing a dependency on bleeding-edge astroid
142159
# for pylint CI pipelines generally, even though we want to use astroid main
143160
# for the purpose of diffing emitted messages and generating PR comments.
144-
messages = list(chain.from_iterable(packages.values()))
145-
astroid_errors = [msg for msg in messages if msg["symbol"] == "astroid-error"]
146-
other_fatal_msgs = [
147-
msg
148-
for msg in messages
149-
if msg["type"] == "fatal" and msg["symbol"] != "astroid-error"
150-
]
151161
if astroid_errors:
152162
warnings.warn(f"Fatal errors traced to astroid: {astroid_errors}")
153163
assert not other_fatal_msgs, other_fatal_msgs

0 commit comments

Comments
 (0)