Skip to content

Commit

Permalink
testrunner: add a junitxml merging script
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed May 21, 2012
1 parent 5ebf4e9 commit 3c67afd
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions testrunner/junitmerge.py
@@ -0,0 +1,49 @@
"""
simple scrpt for junitxml file merging
"""

from lxml.etree import parse, Element, tostring
from collections import defaultdict
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--out')
parser.add_argument('path', nargs='...')

opts = parser.parse_args()

files = []

for path in opts.path:
files.append(parse(path))


accum = defaultdict(int)
children = []

for item in files:
root = item.getroot()
for key, value in root.attrib.items():
if not value:
continue
value = float(value) if '.' in value else int(value)
accum[key] += value
children.extend(root)




assert len(children) == sum(accum[x] for x in 'tests errors skips'.split())

children.sort(key=lambda x:(x.attrib['classname'], x.attrib['name']))



new = Element('testsuite', dict((k, str(v)) for k, v in accum.items()))
new.extend(children)

data = tostring(new)

with open(opts.out, 'w') as fp:
fp.write(data)

0 comments on commit 3c67afd

Please sign in to comment.