changeset 21450:a6e40416f172

run-tests: report test duration in Test.tearDown()
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Apr 2014 15:00:13 -0700
parents aedf18bcde11
children 1b3a1ebdcfee
files tests/run-tests.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sun Apr 20 14:58:36 2014 -0700
+++ b/tests/run-tests.py	Sun Apr 20 15:00:13 2014 -0700
@@ -359,6 +359,7 @@
         self._finished = None
         self._ret = None
         self._out = None
+        self._duration = None
 
         # If we're not in --debug mode and reference output file exists,
         # check test output against it.
@@ -386,6 +387,7 @@
         self._finished = False
         self._ret = None
         self._out = None
+        self._duration = None
 
     def run(self):
         """Run this test instance.
@@ -435,13 +437,14 @@
         starttime = time.time()
         try:
             ret, out = self._run(testtmp, replacements, env)
-            duration = time.time() - starttime
+            self._duration = time.time() - starttime
             self._finished = True
             self._ret = ret
             self._out = out
         except KeyboardInterrupt:
-            duration = time.time() - starttime
-            log('INTERRUPTED: %s (after %d seconds)' % (self.name, duration))
+            self._duration = time.time() - starttime
+            log('INTERRUPTED: %s (after %d seconds)' % (self.name,
+                                                        self._duration))
             raise
         except Exception, e:
             return self.fail('Exception during execution: %s' % e, 255)
@@ -518,12 +521,14 @@
             sys.stdout.flush()
             iolock.release()
 
-        self._runner.times.append((self.name, duration))
+        if not self._unittest:
+            self.tearDown()
 
         return res
 
     def tearDown(self):
         """Tasks to perform after run()."""
+        self._runner.times.append((self.name, self._duration))
 
     def _run(self, testtmp, replacements, env):
         # This should be implemented in child classes to run tests.