run-tests: keep track of test start and stop in MercurialTest.run()
This brings run() more compatible with unittest.TestCase.run()
--- a/tests/run-tests.py Sun Apr 20 14:52:57 2014 -0700
+++ b/tests/run-tests.py Sun Apr 20 14:55:33 2014 -0700
@@ -1364,42 +1364,46 @@
# Need to stash away the TestResult since we do custom things
# with it.
def run(self, result):
- try:
- t.setUp()
- except (KeyboardInterrupt, SystemExit):
- raise
- except Exception:
- result.addError(self, sys.exc_info())
- return
-
- success = False
+ result.startTest(self)
try:
- self.runTest()
- except KeyboardInterrupt:
- raise
- except SkipTest, e:
- result.addSkip(self, str(e))
- except IgnoreTest, e:
- result.addIgnore(self, str(e))
- except WarnTest, e:
- result.addWarn(self, str(e))
- except self.failureException:
- result.addFailure(self, sys.exc_info())
- except Exception:
- result.addError(self, sys.exc_info())
- else:
- success = True
+ try:
+ t.setUp()
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except Exception:
+ result.addError(self, sys.exc_info())
+ return
- try:
- t.tearDown()
- except (KeyboardInterrupt, SystemExit):
- raise
- except Exception:
- result.addError(self, sys.exc_info())
success = False
+ try:
+ self.runTest()
+ except KeyboardInterrupt:
+ raise
+ except SkipTest, e:
+ result.addSkip(self, str(e))
+ except IgnoreTest, e:
+ result.addIgnore(self, str(e))
+ except WarnTest, e:
+ result.addWarn(self, str(e))
+ except self.failureException:
+ result.addFailure(self, sys.exc_info())
+ except Exception:
+ result.addError(self, sys.exc_info())
+ else:
+ success = True
- if success:
- result.addSuccess(self)
+ try:
+ t.tearDown()
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except Exception:
+ result.addError(self, sys.exc_info())
+ success = False
+
+ if success:
+ result.addSuccess(self)
+ finally:
+ result.stopTest(self)
def runTest(self):
code, tname, msg = t.run()