Jenkinsfile: prepend environment name to tests results classname
This commit is contained in:
parent
e8a1a7221c
commit
84efabd886
|
@ -22,7 +22,8 @@ pip install tox"""
|
||||||
utils.publish_coverage_native('index.html')
|
utils.publish_coverage_native('index.html')
|
||||||
utils.publish_pylint('pylint.out')
|
utils.publish_pylint('pylint.out')
|
||||||
}
|
}
|
||||||
junit 'junit*.xml'
|
sh './merge-junit-results.py junit-*.xml >junit.xml'
|
||||||
|
junit 'junit.xml'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Corey Goldberg, Dec 2012
|
||||||
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
|
||||||
|
"""Merge multiple JUnit XML files into a single results file.
|
||||||
|
Output dumps to sdtdout.
|
||||||
|
example usage:
|
||||||
|
$ python merge_junit_results.py results1.xml results2.xml > results.xml
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = sys.argv[1:]
|
||||||
|
if not args:
|
||||||
|
usage()
|
||||||
|
sys.exit(2)
|
||||||
|
if '-h' in args or '--help' in args:
|
||||||
|
usage()
|
||||||
|
sys.exit(2)
|
||||||
|
merge_results(args[:])
|
||||||
|
|
||||||
|
|
||||||
|
def merge_results(xml_files):
|
||||||
|
failures = 0
|
||||||
|
tests = 0
|
||||||
|
errors = 0
|
||||||
|
time = 0.0
|
||||||
|
cases = []
|
||||||
|
|
||||||
|
for file_name in xml_files:
|
||||||
|
tree = ET.parse(file_name)
|
||||||
|
test_suite = tree.getroot()
|
||||||
|
failures += int(test_suite.attrib['failures'])
|
||||||
|
tests += int(test_suite.attrib['tests'])
|
||||||
|
errors += int(test_suite.attrib['errors'])
|
||||||
|
time += float(test_suite.attrib['time'])
|
||||||
|
name = test_suite.attrib.get('name', '')
|
||||||
|
for child in test_suite.getchildren():
|
||||||
|
child.attrib['classname'] = '%s-%s' % (name, child.attrib.get('classname', ''))
|
||||||
|
cases.append(test_suite.getchildren())
|
||||||
|
|
||||||
|
new_root = ET.Element('testsuite')
|
||||||
|
new_root.attrib['failures'] = '%s' % failures
|
||||||
|
new_root.attrib['tests'] = '%s' % tests
|
||||||
|
new_root.attrib['errors'] = '%s' % errors
|
||||||
|
new_root.attrib['time'] = '%s' % time
|
||||||
|
for case in cases:
|
||||||
|
new_root.extend(case)
|
||||||
|
new_tree = ET.ElementTree(new_root)
|
||||||
|
ET.dump(new_tree)
|
||||||
|
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
this_file = os.path.basename(__file__)
|
||||||
|
print('Usage: %s results1.xml results2.xml' % this_file)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
2
tox.ini
2
tox.ini
|
@ -30,7 +30,7 @@ deps =
|
||||||
pytest-django
|
pytest-django
|
||||||
pytest-cov
|
pytest-cov
|
||||||
commands =
|
commands =
|
||||||
py.test {env:COVERAGE:} --junit-xml=junit-{envname}.xml {posargs:tests}
|
py.test {env:COVERAGE:} -o junit_suite_name={envname} --junit-xml=junit-{envname}.xml {posargs:tests}
|
||||||
|
|
||||||
[testenv:pylint]
|
[testenv:pylint]
|
||||||
deps =
|
deps =
|
||||||
|
|
Loading…
Reference in New Issue