Bug 1284502 - Marionette harness should log exceptions from run() only once. r=maja_zf
authorHenrik Skupin <mail@hskupin.info>
Mon, 25 Jul 2016 18:23:26 +0200
changeset 331598 5c6a56bb4a6cb28028b4206bcb3f2cb86baa0528
parent 331597 5125ae09224aa5358f923b792a84f3f0e0a6c256
child 331599 215d196020ff91ba64d3c3965135daa8d2b3972f
child 331705 4a4de3609f4e76bbfb7653167abb035680ac67dc
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1284502
milestone50.0a1
Bug 1284502 - Marionette harness should log exceptions from run() only once. r=maja_zf Whenever an exception is raised while tests are executed, the log error message should only be printed once. As best this should happen in `cli()`, so that subclasses can better set their own behavior, and we safe us from re-raising the exception. MozReview-Commit-ID: 5NLBnJAjUMQ
testing/marionette/harness/marionette/runtests.py
--- a/testing/marionette/harness/marionette/runtests.py
+++ b/testing/marionette/harness/marionette/runtests.py
@@ -57,44 +57,39 @@ class MarionetteHarness(object):
         args.logger = logger
         return vars(args)
 
     def process_args(self):
         if self.args.get('pydebugger'):
             self._testcase_class.pydebugger = __import__(self.args['pydebugger'])
 
     def run(self):
-        try:
-            self.process_args()
-            tests = self.args.pop('tests')
-            runner = self._runner_class(**self.args)
-            runner.run_tests(tests)
-            return runner.failed + runner.crashed
-        except Exception:
-            logger = self.args.get('logger')
-            if logger:
-                logger.error('Failure during test execution.',
-                                       exc_info=True)
-            raise
+        self.process_args()
+        tests = self.args.pop('tests')
+        runner = self._runner_class(**self.args)
+        runner.run_tests(tests)
+        return runner.failed + runner.crashed
 
 
 def cli(runner_class=MarionetteTestRunner, parser_class=MarionetteArguments,
         harness_class=MarionetteHarness, testcase_class=MarionetteTestCase, args=None):
     """
     Call the harness to parse args and run tests.
 
     The following exit codes are expected:
     - Test failures: 10
     - Harness/other failures: 1
     - Success: 0
     """
     logger = mozlog.commandline.setup_logging('Marionette test runner', {})
     try:
-        failed = harness_class(runner_class, parser_class, testcase_class, args=args).run()
+        harness_instance = harness_class(runner_class, parser_class, testcase_class,
+                                         args=args)
+        failed = harness_instance.run()
         if failed > 0:
             sys.exit(10)
     except Exception:
-        logger.error('Failure during harness setup', exc_info=True)
+        logger.error('Failure during harness execution', exc_info=True)
         sys.exit(1)
     sys.exit(0)
 
 if __name__ == "__main__":
     cli()