Page MenuHomePhabricator
Paste P7797

T188717 parse-testsuites.py
ActivePublic

Authored by hashar on Nov 13 2018, 12:33 PM.
Tags
None
Referenced Files
F27211787: T188717 parse-testsuites.py
Nov 13 2018, 12:33 PM
Subscribers
None
#!/usr/bin/env python3
import argparse
import xml.etree.ElementTree as ET
parser = argparse.ArgumentParser()
parser.add_argument('file', help='Junit file to process')
args = parser.parse_args()
testsuites = ET.parse(args.file).findall('.//testsuite')
for testsuite in testsuites:
msg = '{name}'
skipped = (
'skipped' in testsuite.attrib
and int(testsuite.attrib['skipped']) > 0
)
no_tests = (
int(testsuite.attrib['tests']) == 0
and int(testsuite.attrib['assertions']) == 0
)
if skipped or no_tests:
msg = msg + ' SKIPPED'
else:
msg = msg + ' {tests} tests'
try:
print(msg.format_map(testsuite.attrib))
except KeyError as e:
print('Missing key in ', testsuite.attrib)
raise e