[Piglit] [PATCH 1/2] framework/summary.py: raise a FatalError for name collision

Ben Widawsky ben at bwidawsk.net
Wed Jun 10 11:01:52 PDT 2015


This patch is:
Tested-by: Ben Widawsky <ben at bwidawsk.net>

For patch 2, I'd prefer to just always do the rename, as long as you don't touch
the original data. I don't see a usecase where anyone would expect and act upon
this failure. If you must, provide a flag to not do the rename.

(If I were being a pedant I would also say you should have patch1 refer to a
tool that doesn't exist until the next patch, but meh).

Thanks.

On Tue, Jun 09, 2015 at 04:43:02PM -0700, Dylan Baker wrote:
> When two json results have the same "name" value in the root of the json
> dictionary, piglit will try to create two directories with the same
> name. In this event an OSError will be raised to the top level exception
> handler, resulting in a bug warning.
> 
> This patch raises an expected error, giving the user advice on resolving
> the issue.
> 
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  framework/summary.py | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/framework/summary.py b/framework/summary.py
> index 14eaf05..ecd59f1 100644
> --- a/framework/summary.py
> +++ b/framework/summary.py
> @@ -31,13 +31,14 @@ import re
>  import getpass
>  import sys
>  import posixpath
> +import errno
>  
>  from mako.template import Template
>  
>  # a local variable status exists, prevent accidental overloading by renaming
>  # the module
>  import framework.status as so
> -from framework import grouptools, backends
> +from framework import grouptools, backends, exceptions
>  
>  __all__ = [
>      'Summary',
> @@ -475,7 +476,17 @@ class Summary:
>          # Iterate across the tests creating the various test specific files
>          for each in self.results:
>              name = escape_pathname(each.name)
> -            os.mkdir(path.join(destination, name))
> +            try:
> +                os.mkdir(path.join(destination, name))
> +            except OSError as e:
> +                if e.errno == errno.EEXIST:
> +                    raise exceptions.PiglitFatalError(
> +                        'Two or more of your results have the same "name" '
> +                        'attribute. Try changing one or more of the "name" '
> +                        'values in your json files.\n'
> +                        'Duplicate value: {}'.format(name))
> +                else:
> +                    raise e
>  
>              if each.time_elapsed is not None:
>                  time = datetime.timedelta(0, each.time_elapsed)
> -- 
> 2.4.2
> 


More information about the Piglit mailing list