[Piglit] [PATCH] junit.py: Escape `api`/`search` in test's classname too.

Mark Janes mark.a.janes at intel.com
Mon Apr 27 17:58:43 PDT 2015


Reviewed-by: Mark Janes <mark.a.janes at intel.com>

Jose Fonseca <jfonseca at vmware.com> writes:

> If `api` appears in the middle of the test classname, like it happens
> with all `spec/glsl-1.20/api/getactiveattrib *` tests, then Jenkins will
> intercept it making it impossible to see individual tests results.
> Therefore, just like the testname, it must be escaped.
>
> This escaping will affect the expected failure/crash test matching.  I
> can't think of another solution though...
> ---
>  framework/backends/junit.py | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/framework/backends/junit.py b/framework/backends/junit.py
> index 3602f9e..c6219e2 100644
> --- a/framework/backends/junit.py
> +++ b/framework/backends/junit.py
> @@ -40,6 +40,15 @@ __all__ = [
>  ]
>  
>  
> +junitSpecialNames = ('api', 'search')
> +
> +def junitEscape(name):
> +    name = name.replace('.', '_')
> +    if name in junitSpecialNames:
> +        name += '_'
> +    return name
> +
> +
>  class JUnitBackend(FileBackend):
>      """ Backend that produces ANT JUnit XML
>  
> @@ -161,8 +170,9 @@ class JUnitBackend(FileBackend):
>          # classname), and replace piglits '/' separated groups with '.', after
>          # replacing any '.' with '_' (so we don't get false groups).
>          classname, testname = grouptools.splitname(name)
> -        classname = classname.replace('.', '_')
> -        classname = classname.replace(grouptools.SEPARATOR, '.')
> +        classname = classname.split(grouptools.SEPARATOR)
> +        classname = map(junitEscape, classname)
> +        classname = '.'.join(classname)
>  
>          # Add the test to the piglit group rather than directly to the root
>          # group, this allows piglit junit to be used in conjunction with other
> @@ -177,7 +187,7 @@ class JUnitBackend(FileBackend):
>          # The testname variable is used in the calculate_result
>          # closure, and must not have the suffix appended.
>          full_test_name = testname + self._test_suffix
> -        if full_test_name in ('api', 'search'):
> +        if full_test_name in junitSpecialNames:
>              testname += '_'
>              full_test_name = testname + self._test_suffix
>  
> -- 
> 2.1.0


More information about the Piglit mailing list