commit: 02804d8cf4be687f461066a3025bcad9210964b5 Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> AuthorDate: Fri Jan 20 20:47:51 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Fri Jan 20 20:49:34 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=02804d8c
scan: fix quiet mode with keywords Resolves: https://github.com/pkgcore/pkgcheck/issues/413 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcheck/scripts/argparse_actions.py | 4 ++++ tests/scripts/test_pkgcheck_scan.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/pkgcheck/scripts/argparse_actions.py b/src/pkgcheck/scripts/argparse_actions.py index 67a18f73..02053cf9 100644 --- a/src/pkgcheck/scripts/argparse_actions.py +++ b/src/pkgcheck/scripts/argparse_actions.py @@ -302,6 +302,10 @@ class KeywordArgs(arghparse.CommaSeparatedNegations): enabled_keywords = set().union(*(c.known_results for c in namespace.enabled_checks)) namespace.filtered_keywords = enabled_keywords - disabled_keywords + if namespace.verbosity < 0: # quiet mode, include only errors + namespace.filtered_keywords = { + x for x in namespace.filtered_keywords if x.level == "error" + } # restrict enabled checks if none have been selected if not namespace.selected_checks: namespace.enabled_checks = set() diff --git a/tests/scripts/test_pkgcheck_scan.py b/tests/scripts/test_pkgcheck_scan.py index 7d191ee5..e7b024dd 100644 --- a/tests/scripts/test_pkgcheck_scan.py +++ b/tests/scripts/test_pkgcheck_scan.py @@ -499,6 +499,11 @@ class TestPkgcheckScan: results = list(self.scan(self.scan_args + ["-r", repo.location, arg])) assert not results + results = list( + self.scan(self.scan_args + ["-r", repo.location, "-q", "-k=-UnknownKeywords"]) + ) + assert not results + def test_explict_skip_check(self): """SkipCheck exceptions are raised when triggered for explicitly enabled checks.""" error = "network checks not enabled"
