forked from thepian/pypy
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testrunner: add a junitxml merging script
- Loading branch information
1 parent
5ebf4e9
commit 3c67afd
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|