[Piglit] [PATCH] framework/backends/json: support non-piglit junit files
Mark Janes
mark.a.janes at intel.com
Wed Oct 26 23:30:12 UTC 2016
The junit loader is unnecessarily strict with the input that it
accepts. It expects input generated by piglit, but can be made to
handle junit from other test suites like crucible.
---
framework/backends/junit.py | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index 4c9b7af..ab14074 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -361,14 +361,17 @@ def _load(results_file):
else:
run_result.name = 'junit result'
- tree = etree.parse(results_file).getroot().find('.//testsuite[@name="piglit"]')
+ tree = etree.parse(results_file).getroot().find('.//testsuite')
for test in tree.iterfind('testcase'):
result = results.TestResult()
# Take the class name minus the 'piglit.' element, replace junit's '.'
# separator with piglit's separator, and join the group and test names
- name = test.attrib['classname'].split('.', 1)[1]
+ name = test.attrib['name']
+ if 'classname' in test.attrib:
+ name = grouptools.join(test.attrib['classname'], name)
name = name.replace('.', grouptools.SEPARATOR)
- name = grouptools.join(name, test.attrib['name'])
+ if name.startswith("piglit"):
+ name = name.split(grouptools.SEPARATOR, 1)[1]
# Remove the trailing _ if they were added (such as to api and search)
if name.endswith('_'):
@@ -378,14 +381,23 @@ def _load(results_file):
# This is the fallback path, we'll try to overwrite this with the value
# in stderr
- result.time = results.TimeAttribute(end=float(test.attrib['time']))
- result.err = test.find('system-err').text
+ result.time = results.TimeAttribute()
+ if 'time' in test.attrib:
+ result.time = results.TimeAttribute(end=float(test.attrib['time']))
+ result.err = ""
+ syserr = test.find('system-err')
+ if syserr is not None:
+ result.err = syserr.text
# The command is prepended to system-out, so we need to separate those
# into two separate elements
- out = test.find('system-out').text.split('\n')
- result.command = out[0]
- result.out = '\n'.join(out[1:])
+ out_tag = test.find('system-out')
+ result.out = ""
+ result.command = ""
+ if out_tag is not None:
+ out = out_tag.text.split('\n')
+ result.command = out[0]
+ result.out = '\n'.join(out[1:])
# Try to get the values in stderr for time and pid
for line in result.err.split('\n'):
--
2.9.3
More information about the Piglit
mailing list