diff --git a/analyzer/tests/functional/skip/test_skip.py b/analyzer/tests/functional/skip/test_skip.py index 1eb21eae88..daa5d8ed3d 100644 --- a/analyzer/tests/functional/skip/test_skip.py +++ b/analyzer/tests/functional/skip/test_skip.py @@ -12,7 +12,7 @@ of skipped reports from the report files. """ - +import json import os import plistlib import subprocess @@ -38,7 +38,7 @@ def setUp(self): self.report_dir = os.path.join(self.test_workspace, "reports") self.test_dir = os.path.join(os.path.dirname(__file__), 'test_files') - def __test_skip(self): + def test_skip(self): """Analyze a project with a skip file.""" test_dir = os.path.join(self.test_dir, "simple") build_json = os.path.join(self.test_workspace, "build.json") @@ -174,3 +174,24 @@ def test_analyze_only_header(self): for f in report_dir_files])) self.assertTrue(any(["b.cpp" in f for f in report_dir_files])) + + # Get reports only from the header file. + cmd = [ + self._codechecker_cmd, "parse", self.report_dir, + "--file", "*/lib.h", + "--export", "json"] + + process = subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=test_dir, + encoding="utf-8", + errors="ignore") + out, err = process.communicate() + + errcode = process.returncode + self.assertEqual(errcode, 2) + + data = json.loads(out) + self.assertTrue(len(data['reports'])) diff --git a/tools/report-converter/codechecker_report_converter/report/__init__.py b/tools/report-converter/codechecker_report_converter/report/__init__.py index 1c5980cf3b..4c8a91fcf7 100644 --- a/tools/report-converter/codechecker_report_converter/report/__init__.py +++ b/tools/report-converter/codechecker_report_converter/report/__init__.py @@ -512,12 +512,10 @@ def review_status(self) -> str: def skip(self, skip_handler: Optional[SkipListHandler]) -> bool: """ True if the report should be skipped. """ - if skip_handler: - for file_path in self.original_files: - if skip_handler(file_path): - return True + if not skip_handler: + return False - return False + return skip_handler(self.file.original_path) def to_json(self) -> Dict: """ Creates a JSON dictionary. """