diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4127d4e..3190c97 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Changelog TBA === +* To match how we group test cases, JUnit output ``failures`` count is now the amount of files with errors. (#431) * Fixed a whitespace/newline false positive for control conditions containing lambdas. (#410) 2.0.2 (2025-04-08) diff --git a/cpplint.py b/cpplint.py index 07687d2..e02c614 100755 --- a/cpplint.py +++ b/cpplint.py @@ -1547,7 +1547,7 @@ def AddJUnitFailure(self, filename, linenum, message, category, confidence): def FormatJUnitXML(self): num_errors = len(self._junit_errors) - num_failures = len(self._junit_failures) + num_failures = len({failure[0] for failure in self._junit_failures}) testsuite = xml.etree.ElementTree.Element("testsuite") testsuite.attrib["errors"] = str(num_errors) diff --git a/cpplint_unittest.py b/cpplint_unittest.py index d568251..d189a3d 100755 --- a/cpplint_unittest.py +++ b/cpplint_unittest.py @@ -5071,7 +5071,7 @@ def testJUnitXML(self): ] expected = ( '\n' - '' + '' '5: FailMsg1 [category/subcategory]' " [3]\n19: FailMsg3 [category/subcategory] [3]" '99: FailMsg2 ' diff --git a/samples/silly-sample/junit.def b/samples/silly-sample/junit.def index c4dce11..30bca44 100644 --- a/samples/silly-sample/junit.def +++ b/samples/silly-sample/junit.def @@ -3,7 +3,7 @@ 1 -0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5] +0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5] 1: Include the directory when naming header files [build/include_subdir] [4] 3: At least two spaces is best between code and comments [whitespace/comments] [2] 3: Should have a space between // and comment [whitespace/comments] [4]