Skip to content

Commit

Permalink
Merge pull request Ericsson#3559 from csordasmarton/fix_skip_reports
Browse files Browse the repository at this point in the history
[cli] Fix skipping reports
  • Loading branch information
bruntib authored Jan 4, 2022
2 parents 72ee511 + aaa1fe6 commit 8ddb9bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
25 changes: 23 additions & 2 deletions analyzer/tests/functional/skip/test_skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
of skipped reports from the report files.
"""


import json
import os
import plistlib
import subprocess
Expand All @@ -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")
Expand Down Expand Up @@ -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']))
Original file line number Diff line number Diff line change
Expand Up @@ -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. """
Expand Down

0 comments on commit 8ddb9bd

Please sign in to comment.