MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / runCheck

Function runCheck

test/tools/htmlreport/test_htmlreport.py:119–152  ·  view source on GitHub ↗

Run cppcheck and cppcheck-htmlreport. Yield a tuple containing the resulting HTML report index and the directory path.

(source_filename=None, xml_version='1', xml_filename=None, checkers_filename=None)

Source from the content-addressed store, hash-verified

117
118@contextlib.contextmanager
119def runCheck(source_filename=None, xml_version='1', xml_filename=None, checkers_filename=None):
120 """Run cppcheck and cppcheck-htmlreport.
121
122 Yield a tuple containing the resulting HTML report index and the directory
123 path.
124
125 """
126 output_directory = tempfile.TemporaryDirectory(dir='.')
127 if xml_filename is None:
128 assert source_filename
129 xml_filename = os.path.join(output_directory.name, 'output.xml')
130
131 with open(xml_filename, 'w') as output_file:
132 subprocess.check_call(
133 [CPPCHECK_BIN, '--xml', source_filename,
134 '--xml-version=' + xml_version],
135 stderr=output_file)
136
137 assert os.path.exists(xml_filename)
138
139 args = [*HTML_REPORT_BIN,
140 '--file=' + os.path.realpath(xml_filename),
141 '--report-dir=' + os.path.realpath(output_directory.name)]
142 if checkers_filename:
143 args.append('--checkers-report-file=' + os.path.realpath(checkers_filename))
144
145 subprocess.check_call(
146 args,
147 cwd=TEST_TOOLS_DIR)
148
149 with open(os.path.join(output_directory.name, 'index.html')) as index_file:
150 index_contents = index_file.read()
151
152 yield index_contents, output_directory
153
154
155if __name__ == '__main__':

Callers 6

checkReportErrorMethod · 0.85
checkReportNoErrorMethod · 0.85
testMissingIncludeMethod · 0.85
testAddCheckersReportMethod · 0.85
testAddTimestampMethod · 0.85
testSeverityFilterBarMethod · 0.85

Calls 3

joinMethod · 0.45
existsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected