diff options
author | Jacob Walls <jacobtylerwalls@gmail.com> | 2022-05-30 16:39:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-30 16:39:38 -0400 |
commit | c29bba61a16dbffb807c5af91208dd6a116435e3 (patch) | |
tree | 57b483e59c02992398f5054d259637606bd4f9e4 /tests | |
parent | d3180eafff77fc6eb56d0418e997cd6e0f31ede8 (diff) | |
download | pylint-git-c29bba61a16dbffb807c5af91208dd6a116435e3.tar.gz |
Fail "new primer" runs on fatal errors, like the "old primer" (#6746)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/primer/primer_tool.py | 20 | ||||
-rw-r--r-- | tests/profile/test_profile_against_externals.py | 2 |
2 files changed, 20 insertions, 2 deletions
diff --git a/tests/primer/primer_tool.py b/tests/primer/primer_tool.py index 643c1bff8..45c4d1b10 100644 --- a/tests/primer/primer_tool.py +++ b/tests/primer/primer_tool.py @@ -7,7 +7,9 @@ from __future__ import annotations import argparse import json import sys +import warnings from io import StringIO +from itertools import chain from pathlib import Path from typing import Dict, List, Union @@ -134,6 +136,22 @@ class Primer: ) as f: json.dump(packages, f) + # Fail loudly (and fail CI pipelines) if any fatal errors are found, + # unless they are astroid-errors, in which case just warn. + # This is to avoid introducing a dependency on bleeding-edge astroid + # for pylint CI pipelines generally, even though we want to use astroid main + # for the purpose of diffing emitted messages and generating PR comments. + messages = list(chain.from_iterable(packages.values())) + astroid_errors = [msg for msg in messages if msg["symbol"] == "astroid-error"] + other_fatal_msgs = [ + msg + for msg in messages + if msg["type"] == "fatal" and msg["symbol"] != "astroid-error" + ] + if astroid_errors: + warnings.warn(f"Fatal errors traced to astroid: {astroid_errors}") + assert not other_fatal_msgs, other_fatal_msgs + def _handle_compare_command(self) -> None: with open(self.config.base_file, encoding="utf-8") as f: main_dict: PackageMessages = json.load(f) @@ -246,7 +264,7 @@ class Primer: arguments += [f"--rcfile={data.pylintrc_relpath}"] output = StringIO() reporter = JSONReporter(output) - Run(arguments, reporter=reporter, do_exit=False) + Run(arguments, reporter=reporter, exit=False) return json.loads(output.getvalue()) @staticmethod diff --git a/tests/profile/test_profile_against_externals.py b/tests/profile/test_profile_against_externals.py index 33b25efbc..579a5bc9c 100644 --- a/tests/profile/test_profile_against_externals.py +++ b/tests/profile/test_profile_against_externals.py @@ -46,7 +46,7 @@ def test_run(tmp_path, name, git_repo): filepaths = _get_py_files(scanpath=str(checkoutdir)) print(f"Have {len(filepaths)} files") - runner = Run(filepaths, reporter=Reporter(), do_exit=False) + runner = Run(filepaths, reporter=Reporter(), exit=False) print( f"Had {len(filepaths)} files with {len(runner.linter.reporter.messages)} messages" |