[Piglit] [PATCH v2] framework/backends/json: support non-piglit junit files
Dylan Baker
dylan at pnwbakers.com
Thu Oct 27 21:30:31 UTC 2016
Quoting Mark Janes (2016-10-26 17:37:12)
> 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.
>
> v2: Remove unnecessary initializers
> Conditionally parse command for piglit tests
> ---
> framework/backends/junit.py | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/framework/backends/junit.py b/framework/backends/junit.py
> index 4c9b7af..4032db9 100644
> --- a/framework/backends/junit.py
> +++ b/framework/backends/junit.py
> @@ -361,14 +361,19 @@ 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'])
> + is_piglit = False
> + if name.startswith("piglit"):
> + is_piglit = True
> + 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 +383,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']))
> + 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')
> + if out_tag is not None:
> + if is_piglit:
> + out = out_tag.text.split('\n')
> + result.command = out[0]
> + result.out = '\n'.join(out[1:])
> + else:
> + result.out = out_tag.text
>
> # Try to get the values in stderr for time and pid
> for line in result.err.split('\n'):
> --
> 2.9.3
>
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20161027/48a53274/attachment.sig>
More information about the Piglit
mailing list