[Piglit] [PATCH] framework: Never redirect sys.stderr to /dev/null.

Dylan Baker baker.dylan.c at gmail.com
Mon Dec 7 10:20:40 PST 2015


On Mon, Dec 07, 2015 at 03:31:59PM +0000, Jose Fonseca wrote:
> I figured out how to not redirect stderr, but I can't figure out how to not
> catch the exceptions for the life of me.
> 
> There's not a single exception handler, but many.  I identified some as
> drafted in the attached, but there are apparently more.
> 
> They are hidden inside accessors and function decorators, and who knows what
> more...
> 
> Jose

> diff --git a/framework/exceptions.py b/framework/exceptions.py
> index fdd1f1f..f93dda8 100644
> --- a/framework/exceptions.py
> +++ b/framework/exceptions.py
> @@ -32,43 +32,9 @@ __all__ = [
>      'handler',
>  ]
>  
> -_DEBUG = bool(os.environ.get('PIGLIT_DEBUG', False))
> -
>  
>  def handler(func):
> -    """Decorator function for handling errors in an entry point.
> -
> -    This will handle expected errors (PiglitFatalError), and unexpected errors,
> -    either PiglitInternalErrors or PiglitExceptions, as well as handling
> -    generic Exceptions
> -
> -    """
> -
> -    @functools.wraps(func)
> -    def _inner(*args, **kwargs):
> -        try:
> -            func(*args, **kwargs)
> -        except PiglitFatalError as e:
> -            print('Fatal Error: {}'.format(str(e)), file=sys.stderr)
> -            sys.exit(1)
> -        except (PiglitInternalError, PiglitException) as e:
> -            print('Warning: An internal exception that should have '
> -                  'been handled was not. This is bug and should be reported.\n'
> -                  'BUG: {}'.format(str(e)),
> -                  file=sys.stderr)
> -            if _DEBUG:
> -                raise

I think the behavior you want is to drop "if _DEBUG" (both here and
below), and just raise unconditionally in these cases.

If that is what you want, you have my r-b on that.

> -            sys.exit(1)
> -        except Exception as e:  # pylint: disable=broad-except
> -            print('Warning: A python exception that should have '
> -                  'been handled was not. This is bug and should be reported.\n'
> -                  'BUG: {}'.format(str(e)),
> -                  file=sys.stderr)
> -            if _DEBUG:
> -                raise
> -            sys.exit(1)
> -
> -    return _inner
> +    return func
>  
>  
>  class PiglitException(Exception):
> diff --git a/framework/test/base.py b/framework/test/base.py
> index 378f185..2653491 100644
> --- a/framework/test/base.py
> +++ b/framework/test/base.py
> @@ -175,21 +175,23 @@ class Test(object):
>          log.start(path)
>          # Run the test
>          if options.OPTIONS.execute:
> -            try:
> +            #try:
> +            if 1:
>                  self.result.time.start = time.time()
>                  dmesg.update_dmesg()
>                  self.run()
>                  self.result.time.end = time.time()
>                  self.result = dmesg.update_result(self.result)
> -            # This is a rare case where a bare exception is okay, since we're
> -            # using it to log exceptions
> -            except:
> -                exc_type, exc_value, exc_traceback = sys.exc_info()
> -                traceback.print_exc(file=sys.stderr)
> -                self.result.result = 'fail'
> -                self.result.exception = "{}{}".format(exc_type, exc_value)
> -                self.result.traceback = "".join(
> -                    traceback.format_tb(exc_traceback))
> +            ## This is a rare case where a bare exception is okay, since we're
> +            ## using it to log exceptions
> +            #except:
> +            #    exc_type, exc_value, exc_traceback = sys.exc_info()
> +            #    traceback.print_exc(file=sys.stderr)
> +            #    self.result.result = 'fail'
> +            #    self.result.exception = "{}{}".format(exc_type, exc_value)
> +            #    self.result.traceback = "".join(
> +            #        traceback.format_tb(exc_traceback))
> +            #    raise
>  
>              log.log(self.result.result)
>          else:
> diff --git a/framework/test/opengl.py b/framework/test/opengl.py
> index 0a7b2d7..8590f5b 100644
> --- a/framework/test/opengl.py
> +++ b/framework/test/opengl.py
> @@ -83,6 +83,7 @@ class WflInfo(object):
>  
>          # FIXME: The version parsing below is full of bugs.  Disable all
>          # wflinfo invocation until they are addressed
> +        raise ValueError
>          raise StopWflinfo('OSError')
>  
>          with open(os.devnull, 'w') as d:

> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20151207/b014c862/attachment.sig>


More information about the Piglit mailing list