Bug 1440405 - Fix faulty assumption that only one log handler can be installed in |mach test/mochitest|, r?froydnj draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 23 Feb 2018 09:40:06 -0500
changeset 758989 0de910fb6a5708dace8276cde61c8a8175b12f3c
parent 758927 6661c077325c35af028f1cdaa660f673cbea39be
push id100243
push userahalberstadt@mozilla.com
push dateFri, 23 Feb 2018 14:41:31 +0000
reviewersfroydnj
bugs1440405
milestone60.0a1
Bug 1440405 - Fix faulty assumption that only one log handler can be installed in |mach test/mochitest|, r?froydnj MozReview-Commit-ID: AzKLAgW5agx
testing/mach_commands.py
testing/mochitest/mach_commands.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -106,31 +106,34 @@ class Test(MachCommandBase):
         files known to the build system.
 
         If resolved tests belong to more than one test type/flavor/harness,
         the harness for each relevant type/flavor will be invoked. e.g. if
         you specify a directory with xpcshell and browser chrome mochitests,
         both harnesses will be invoked.
         """
         from mozlog.commandline import setup_logging
+        from mozlog.handlers import StreamHandler
         from moztest.resolve import get_suite_definition, TestResolver, TEST_SUITES
 
         resolver = self._spawn(TestResolver)
         run_suites, run_tests = resolver.resolve_metadata(what)
 
         if not run_suites and not run_tests:
             print(UNKNOWN_TEST)
             return 1
 
         # Create shared logger
         default_format = self._mach_context.settings['test']['format']
         default_level = self._mach_context.settings['test']['level']
         log = setup_logging('mach-test', log_args, {default_format: sys.stdout},
                             {'level': default_level})
-        log.handlers[0].formatter.inner.summary_on_shutdown = True
+        for handler in log.handlers:
+            if isinstance(handler, StreamHandler):
+                handler.formatter.inner.summary_on_shutdown = True
 
         status = None
         for suite_name in run_suites:
             suite = TEST_SUITES[suite_name]
             kwargs = suite['kwargs']
             kwargs['log'] = log
 
             if 'mach_command' in suite:
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -276,16 +276,17 @@ def verify_host_bin():
 class MachCommands(MachCommandBase):
     @Command('mochitest', category='testing',
              conditions=[is_buildapp_in(*SUPPORTED_APPS)],
              description='Run any flavor of mochitest (integration test).',
              parser=setup_argument_parser)
     def run_mochitest_general(self, flavor=None, test_objects=None, resolve_tests=True, **kwargs):
         from mochitest_options import ALL_FLAVORS
         from mozlog.commandline import setup_logging
+        from mozlog.handlers import StreamHandler
 
         buildapp = None
         for app in SUPPORTED_APPS:
             if is_buildapp_in(app)(self):
                 buildapp = app
                 break
 
         flavors = None
@@ -300,17 +301,19 @@ class MachCommands(MachCommandBase):
             flavors = [f for f, v in ALL_FLAVORS.iteritems() if buildapp in v['enabled_apps']]
 
         if not kwargs.get('log'):
             # Create shared logger
             default_format = self._mach_context.settings['test']['format']
             default_level = self._mach_context.settings['test']['level']
             kwargs['log'] = setup_logging('mach-mochitest', kwargs, {default_format: sys.stdout},
                                           {'level': default_level})
-            kwargs['log'].handlers[0].formatter.inner.summary_on_shutdown = True
+            for handler in kwargs['log'].handlers:
+                if isinstance(handler, StreamHandler):
+                    handler.formatter.inner.summary_on_shutdown = True
 
         from mozbuild.controller.building import BuildDriver
         self._ensure_state_subdir_exists('.')
 
         test_paths = kwargs['test_paths']
         kwargs['test_paths'] = []
 
         mochitest = self._spawn(MochitestRunner)