Patchwork [038,of,179,tests-refactor] run-tests: emit exception failure result from Test.run()

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:37 p.m.
Message ID <4f67c9dbb2bdc7d2a6b9.1399055875@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4533/
State Accepted
Commit 9a5913beaf77ad73e43207824dc0efd4c940271c
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397967022 25200
#      Sat Apr 19 21:10:22 2014 -0700
# Branch stable
# Node ID 4f67c9dbb2bdc7d2a6b9978f5f40c5c6b13ab819
# Parent  684520300db044d417f868fa6157570b33fcae31
run-tests: emit exception failure result from Test.run()

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -629,17 +629,17 @@  class Test(object):
             result.out = out
         except KeyboardInterrupt:
             updateduration()
             log('INTERRUPTED: %s (after %d seconds)' % (self._test,
                                                         result.duration))
             raise
         except Exception, e:
             updateduration()
-            result.exception = e
+            return self.fail('Exception during execution: %s' % e, 255)
 
         killdaemons(env['DAEMON_PIDS'])
 
         result.refout = self._refout
 
         if not options.keep_tmpdir:
             shutil.rmtree(testtmp)
 
@@ -782,17 +782,16 @@  class Test(object):
 
 class TestResult(object):
     """Holds the result of a test execution."""
 
     def __init__(self):
         self.ret = None
         self.out = None
         self.duration = None
-        self.exception = None
         self.refout = None
         self.skipped = False
 
 class PythonTest(Test):
     """A Python-based test."""
     def _run(self, testtmp, replacements, env):
         py3kswitch = self._options.py3k_warnings and ' -3' or ''
         cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self._path)
@@ -1145,19 +1144,16 @@  def runone(options, test, count):
         return skip("unknown test type")
 
     vlog("# Test", test)
 
     t = runner(test, testpath, options, count, ref, err)
     res = TestResult()
     result = t.run(res)
 
-    if res.exception:
-        return t.fail('Exception during execution: %s' % res.exception, 255)
-
     ret = res.ret
     out = res.out
 
     times.append((test, res.duration))
     vlog("# Ret was:", ret)
 
     skipped = res.skipped
     refout = res.refout