Author: Ronny Pfannschmidt <[email protected]>
Branch: 
Changeset: r55146:cea3b8694de3
Date: 2012-05-21 17:23 +0200
http://bitbucket.org/pypy/pypy/changeset/cea3b8694de3/

Log:    testrunner: add a junitxml merging script

diff --git a/testrunner/junitmerge.py b/testrunner/junitmerge.py
new file mode 100644
--- /dev/null
+++ b/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)
+
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to