On 08/12/15 15:42, Dylan Baker wrote:
On Tue, Dec 08, 2015 at 01:23:29PM +0000, Jose Fonseca wrote:
Exceptions were not reaching neither.

Junit is probably still busted.  But the right fix is to not catch
generic Python exceptions, at all.
---
  framework/results.py       | 3 ++-
  framework/test/base.py     | 7 ++++---
  templates/test_result.mako | 8 ++++++++
  3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/framework/results.py b/framework/results.py
index eeffcb7..ef19fd4 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -196,6 +196,7 @@ class TestResult(object):
              'subtests': self.subtests,
              'time': self.time,
              'exception': self.exception,
+            'traceback': self.traceback,
              'dmesg': self.dmesg,
          }
          return obj
@@ -215,7 +216,7 @@ class TestResult(object):
          # pylint: disable=assigning-non-slot
          inst = cls()

-        for each in ['returncode', 'command', 'exception', 'environment',
+        for each in ['returncode', 'command', 'exception', 'traceback', 
'environment',
                       'time', 'result', 'dmesg']:
              if each in dict_:
                  setattr(inst, each, dict_[each])
diff --git a/framework/test/base.py b/framework/test/base.py
index bf998d8..ecd8bd9 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -184,11 +184,12 @@ class Test(object):
              # This is a rare case where a bare exception is okay, since we're
              # using it to log exceptions
              except:
-                exception = sys.exc_info()
+                exc_type, exc_value, exc_traceback = sys.exc_info()
+                traceback.print_exc(file=sysstderr)

typo: sys.stderr

                  self.result.result = 'fail'
-                self.result.exception = "{}{}".format(*exception[:2])
+                self.result.exception = "{}{}".format(exc_type, exc_value)
                  self.result.traceback = "".join(
-                    traceback.format_tb(exception[2]))
+                    traceback.format_tb(exc_traceback))

              log.log(self.result.result)
          else:
diff --git a/templates/test_result.mako b/templates/test_result.mako
index 229a5a7..ff08797 100644
--- a/templates/test_result.mako
+++ b/templates/test_result.mako
@@ -75,6 +75,14 @@
            </pre>${value.command}</pre>
          </td>
        </tr>
+    % if value.exception:
+      <tr>
+        <td>Exception</td>
+        <td>
+          <pre>${value.exception | h}</pre>
+        </td>
+      </tr>
+    % endif
      % if value.traceback:
        <tr>
          <td>Traceback</td>
--
2.5.0

This patch conflates two different issues. one is that you want the
error printed,

Split now.

> one is that it needs to be stored in the json and
presented in the html summary. I'd prefer to see that as two separate
changes.

You said in a previous version that you wanted the suite to stop if you
hit this issue, I sent a patch to do that.

I didn't notice. I wasn't CC'ed.

Jose

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to