diff --git a/scripts/parse_mld_xml.py b/scripts/parse_mld_xml.py new file mode 100644 index 0000000000000000000000000000000000000000..1760b56258695774f90df67a1f6233c94d7bd482 --- /dev/null +++ b/scripts/parse_mld_xml.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import argparse +from xml.etree import ElementTree + +""" +Parse a junit report and create a MLD summary report. +""" + +# Main routine +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Parse a junit report and create a MLD summary report.') + parser.add_argument('xml_report',type=str,help='XML junit report input file, e.g. report-junit.xml') + parser.add_argument('csv_file',type=str,help='Output CSV file, e.g. mld.csv') + args = parser.parse_args() + xml_report = args.xml_report + csv_file = args.csv_file + + mld = {} + + tree = ElementTree.parse(xml_report) + + testsuite = tree.find(".//testsuite") + print(f"Found testsuite with {testsuite.get('tests')} tests and {testsuite.get('failures')} failures.") + + testcases = tree.findall(".//testcase") + + with open(csv_file,'w') as outfile: + for testcase in testcases: + failure = testcase.find(".//failure") + if failure is not None: + system_out = testcase.find(".//system-out") + for line in system_out.text.split('\n'): + if line.startswith('MLD:'): + mld_val = float(line.split()[1]) + fulltestname = testcase.get('file') + "::" + testcase.get('name') + mld[fulltestname] = mld_val + outfile.write(fulltestname + ';' + str(mld_val)+'\n')