Mercurial > hg
changeset 21493:b8f4854ea61a
run-tests: refactor how times are recorded
We now record times in Test.run(), which is a more appropriate place for
it.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Apr 2014 17:21:24 -0700 |
parents | a9c4f4912402 |
children | dcefc4091c86 |
files | tests/run-tests.py |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sun Apr 20 17:13:10 2014 -0700 +++ b/tests/run-tests.py Sun Apr 20 17:21:24 2014 -0700 @@ -355,7 +355,6 @@ self._finished = None self._ret = None self._out = None - self._duration = None self._skipped = None self._testtmp = None @@ -393,7 +392,6 @@ self._finished = False self._ret = None self._out = None - self._duration = None self._skipped = None self._testtmp = os.path.join(self._threadtmp, @@ -406,6 +404,7 @@ def run(self, result): result.startTest(self) + starttime = time.time() try: try: self.setUp() @@ -419,6 +418,10 @@ try: self.runTest() except KeyboardInterrupt: + duration = time.time() - starttime + log('INTERRUPTED: %s (after %d seconds)' % (self.name, + duration)) + self._runner.times.append((self.name, duration)) raise except SkipTest, e: result.addSkip(self, str(e)) @@ -437,6 +440,8 @@ else: success = True + self._runner.times.append((self.name, time.time() - starttime)) + try: self.tearDown() except (KeyboardInterrupt, SystemExit): @@ -486,17 +491,12 @@ vlog('# Test', self.name) - starttime = time.time() try: ret, out = self._run(replacements, env) - self._duration = time.time() - starttime self._finished = True self._ret = ret self._out = out except KeyboardInterrupt: - 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) @@ -573,8 +573,6 @@ vlog("# Ret was:", self._ret) - self._runner.times.append((self.name, self._duration)) - def _run(self, replacements, env): # This should be implemented in child classes to run tests. raise SkipTest('unknown test type')