run-tests: keep track of test start and stop in MercurialTest.run()
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 20 Apr 2014 14:55:33 -0700
changeset 21448 f2dbbcacc763
parent 21447 f8c5b8a288c5
child 21449 aedf18bcde11
run-tests: keep track of test start and stop in MercurialTest.run() This brings run() more compatible with unittest.TestCase.run()
tests/run-tests.py
--- 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()