[Piglit] [PATCH] framework/exceptions.py: Drop PIGLIT_DEBUG

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Fri Dec 18 14:49:43 PST 2015


From: Dylan Baker <baker.dylan.c at gmail.com>

Previously a stack trace would be suppressed in all instances unless
the PIGLIT_DEBUG environment variable was truthy. This was suboptimal
for a number of reasons.

This patch removes that functionality, now only a subset of piglit
specific exceptions that are meant to be suppressed are. All other
exceptions are directly raised, stopping the runner immediately. Other
piglit specific exceptions have been extended to have custom error
messages rather than relying on the handler to add them.

cc: jfonseca at vmware.com
cc: imirkin at alum.mit.edu
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/exceptions.py | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/framework/exceptions.py b/framework/exceptions.py
index fdd1f1f..e0b04d6 100644
--- a/framework/exceptions.py
+++ b/framework/exceptions.py
@@ -21,7 +21,6 @@
 """Exception and error classes for piglit, and exception handlers."""
 
 from __future__ import print_function, absolute_import, division
-import os
 import sys
 import functools
 
@@ -32,8 +31,6 @@ __all__ = [
     'handler',
 ]
 
-_DEBUG = bool(os.environ.get('PIGLIT_DEBUG', False))
-
 
 def handler(func):
     """Decorator function for handling errors in an entry point.
@@ -51,22 +48,6 @@ def handler(func):
         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
-            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
 
@@ -78,6 +59,9 @@ class PiglitException(Exception):
     uncaught that is a bug in piglit.
 
     """
+    def __str__(self):
+        return ('An internal exception that should have been handled was not:'
+                '\n{}'.format(super(PiglitException, self).__str__()))
 
 
 class PiglitInternalError(Exception):
@@ -86,6 +70,9 @@ class PiglitInternalError(Exception):
     These should always be handled.
 
     """
+    def __str__(self):
+        return 'An internal error occured:\n{}'.format(
+            super(PiglitInternalError, self).__str__())
 
 
 class PiglitFatalError(Exception):
-- 
2.6.4



More information about the Piglit mailing list