MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / FormatJUnitXML

Method FormatJUnitXML

src/tests/coding/cpplint.py:1369–1410  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1367 confidence))
1368
1369 def FormatJUnitXML(self):
1370 num_errors = len(self._junit_errors)
1371 num_failures = len(self._junit_failures)
1372
1373 testsuite = xml.etree.ElementTree.Element('testsuite')
1374 testsuite.attrib['errors'] = str(num_errors)
1375 testsuite.attrib['failures'] = str(num_failures)
1376 testsuite.attrib['name'] = 'cpplint'
1377
1378 if num_errors == 0 and num_failures == 0:
1379 testsuite.attrib['tests'] = str(1)
1380 xml.etree.ElementTree.SubElement(testsuite, 'testcase', name='passed')
1381
1382 else:
1383 testsuite.attrib['tests'] = str(num_errors + num_failures)
1384 if num_errors > 0:
1385 testcase = xml.etree.ElementTree.SubElement(testsuite, 'testcase')
1386 testcase.attrib['name'] = 'errors'
1387 error = xml.etree.ElementTree.SubElement(testcase, 'error')
1388 error.text = '\n'.join(self._junit_errors)
1389 if num_failures > 0:
1390 # Group failures by file
1391 failed_file_order = []
1392 failures_by_file = {}
1393 for failure in self._junit_failures:
1394 failed_file = failure[0]
1395 if failed_file not in failed_file_order:
1396 failed_file_order.append(failed_file)
1397 failures_by_file[failed_file] = []
1398 failures_by_file[failed_file].append(failure)
1399 # Create a testcase for each file
1400 for failed_file in failed_file_order:
1401 failures = failures_by_file[failed_file]
1402 testcase = xml.etree.ElementTree.SubElement(testsuite, 'testcase')
1403 testcase.attrib['name'] = failed_file
1404 failure = xml.etree.ElementTree.SubElement(testcase, 'failure')
1405 template = '{0}: {1} [{2}] [{3}]'
1406 texts = [template.format(f[1], f[2], f[3], f[4]) for f in failures]
1407 failure.text = '\n'.join(texts)
1408
1409 xml_decl = '<?xml version="1.0" encoding="UTF-8" ?>\n'
1410 return xml_decl + xml.etree.ElementTree.tostring(testsuite, 'utf-8').decode('utf-8')
1411
1412
1413_cpplint_state = _CppLintState()

Callers 1

mainFunction · 0.80

Calls 3

ElementMethod · 0.80
decodeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected