Skip to content

Commit

Permalink
Add tests for parse summary
Browse files Browse the repository at this point in the history
  • Loading branch information
vodorok committed Oct 15, 2023
1 parent f473627 commit ac389dd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -776,3 +776,17 @@ def test_html_checker_url(self):
encoding="utf-8", errors="ignore") as f:
content = f.read()
self.assertTrue(re.search('"url": null', content))

def test_summary_option(self):
""" Test '--summary' flag of parse command. """
test_project_notes = os.path.join(self.test_workspaces['NORMAL'],
"test_files", "notes")

parse_cmd = ['CodeChecker', 'parse', "--summary",
test_project_notes]

out, _, _ = call_command(parse_cmd, cwd=self.test_dir,
env=self.env)

self.assertIn("Checkers Summary Statistics", out)
self.assertIn("alpha.clone.CloneChecker | 1", out)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
import io
import contextlib

from codechecker_report_converter.report.statistics import Statistics


class TestCheckerSummary(unittest.TestCase):
""" Test the output of the statistics checker summary. """

def test_checker_summary(self):
""" Test the output of the statistics checker summary. """
input = {"Checker_A":1, "Checker_B":2, "Checker_C": 3}
Statistics.write_checker_summary(input)
f = io.StringIO()
with contextlib.redirect_stdout(f):
Statistics.write_checker_summary(input, f)
output = f.getvalue()
self.assertIn("Checker_C | 3", output)
self.assertIn("Checker_B | 2", output)
self.assertIn("Checker_A | 1", output)

# Check if checker_C comes first in the output
self.assertLess(output.find("Checker_C"), output.find("Checker_B"))

0 comments on commit ac389dd

Please sign in to comment.