# HG changeset patch # User Gregory Szorc # Date 1398031213 25200 # Node ID a6e40416f172b8890188bd840247debff42355b4 # Parent aedf18bcde11d35aa029f4419c4531efb6d4417d run-tests: report test duration in Test.tearDown() diff -r aedf18bcde11 -r a6e40416f172 tests/run-tests.py --- 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.