6
from xml.etree import ElementTree
11
def _convert_testcase(tc):
13
'testcase': tc.attrib['name'],
14
'testsuite': tc.attrib['classname'],
15
'command': 'autopilot',
16
'cmd_type': 'testcase_test',
21
t = tc.attrib.get('time', False)
25
for e in tc.getchildren():
26
if e.tag in ('failure', 'error'):
30
# NOTE: this isn't a real thing in UTAH. However, the
31
# qa-dashboard code doesn't care and will display it as skipped
32
x['cmd_type'] = 'testcase_skipped'
35
raise RuntimeError('Unknown element type: %s' % e.tag)
39
def _get_results(stream):
40
tree = ElementTree.fromstring(stream.read())
42
'errors': int(tree.attrib.get('errors', '0')),
43
'failures': int(tree.attrib.get('failures', '0')),
48
'install_type': 'n/a',
51
'build_number': 'n/a',
54
'ran_at': datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'),
57
int(tree.attrib['tests']) - results['errors'] - results['failures']
59
for tc in tree.getchildren():
60
results['commands'].append(_convert_testcase(tc))
65
results = _get_results(stream)
66
print(yaml.safe_dump(results, default_flow_style=False))
69
if __name__ == '__main__':
70
exit(_main(sys.stdin))