Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Commit 2b95e4a

Browse files
committed
Use "error" consistantly rather than "failure" to refer to results from cpplint.
1 parent afd204c commit 2b95e4a

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cpplint JUnit Converter
44
.. image:: https://badge.fury.io/py/cpplint-junit.png
55
:target: http://badge.fury.io/py/cpplint-junit
66

7-
Tool that converts cpplint output to JUnit XML format. Use on your CI servers to get more
7+
Tool that converts ``cpplint`` output to JUnit XML format. Use on your CI servers to get more
88
helpful feedback.
99

1010
Installation
@@ -35,6 +35,11 @@ Convert it to JUnit XML format:
3535
Releases
3636
--------
3737

38+
0.2.2 - 2015-11-14
39+
^^^^^^^^^^^^^^^^^^
40+
41+
Use "error" consistantly rather than "failure" to refer to results from ``cpplint``.
42+
3843
0.2.1 - 2015-10-24
3944
^^^^^^^^^^^^^^^^^^
4045

cpplint_junit.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
from xml.etree import ElementTree
1111

12-
__version__ = '0.2.1'
12+
__version__ = '0.2.2'
1313

1414
EXIT_SUCCESS = 0
1515
EXIT_FAILURE = -1
@@ -36,14 +36,14 @@ def parse_cpplint(file_name):
3636
file_name (str): cpplint output file.
3737
3838
Returns:
39-
Dict[str, List[CpplintFailure]]: Parsed failures grouped by file name.
39+
Dict[str, List[CpplintError]]: Parsed failures grouped by file name.
4040
4141
Raises:
4242
FileNotFoundError: File does not exist.
4343
"""
4444
lines = open(file_name, mode='rt').readlines()
4545

46-
failures = collections.defaultdict(list)
46+
errors = collections.defaultdict(list)
4747
for line in lines:
4848
line = line.rstrip()
4949

@@ -52,34 +52,34 @@ def parse_cpplint(file_name):
5252
error = CpplintError(file=match.group(1),
5353
line=int(match.group(2)),
5454
message=match.group(3))
55-
failures[error.file].append(error)
56-
return failures
55+
errors[error.file].append(error)
56+
return errors
5757

5858

59-
def generate_test_suite(failures, output_file):
59+
def generate_test_suite(errors, output_file):
6060
"""Writes a JUnit test file from parsed cpplint failures.
6161
6262
Args:
63-
failures (Dict[str, List[CpplintFailure]]): Parsed cpplint failures.
63+
errors (Dict[str, List[CpplintError]]): Parsed cpplint failures.
6464
output_file (str): File path to JUnit XML output.
6565
6666
Returns:
6767
Nothing.
6868
"""
6969
test_suite = ElementTree.Element('testsuite')
70-
test_suite.attrib['errors'] = str(len(failures))
70+
test_suite.attrib['errors'] = str(len(errors))
7171
test_suite.attrib['failures'] = str(0)
72-
test_suite.attrib['name'] = 'cpplint failures'
73-
test_suite.attrib['tests'] = str(len(failures))
72+
test_suite.attrib['name'] = 'cpplint errors'
73+
test_suite.attrib['tests'] = str(len(errors))
7474
test_suite.attrib['time'] = str(1)
7575

76-
for file_name, errors in failures.items():
76+
for file_name, errors in errors.items():
7777
test_case = ElementTree.SubElement(test_suite,
7878
'testcase',
7979
name=os.path.relpath(file_name))
8080
for error in errors:
8181
ElementTree.SubElement(test_case,
82-
'failure',
82+
'error',
8383
file=os.path.relpath(error.file),
8484
line=str(error.line),
8585
message='{}: {}'.format(error.line, error.message))
@@ -97,13 +97,13 @@ def main():
9797
args = parse_arguments()
9898

9999
try:
100-
failures = parse_cpplint(args.input_file)
100+
errors = parse_cpplint(args.input_file)
101101
except FileNotFoundError as e:
102102
print(str(e))
103103
return EXIT_FAILURE
104104

105-
if len(failures) > 0:
106-
generate_test_suite(failures, args.output_file)
105+
if len(errors) > 0:
106+
generate_test_suite(errors, args.output_file)
107107

108108
return EXIT_SUCCESS
109109

0 commit comments

Comments
 (0)