Bug 1440405 - Fix faulty assumption that only one log handler can be installed in |mach test/mochitest|, r=froydnj
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 23 Feb 2018 09:40:06 -0500
changeset 405047 f89b5611098e65a40ebea9ced8483133fd908c59
parent 405046 c59239cde97d059bcb747f039d517635d4804a2c
child 405048 cdf9965aa9b9337ab76cfbec9c44231319ddba1c
push id33501
push usernbeleuzu@mozilla.com
push dateSat, 24 Feb 2018 00:22:35 +0000
treeherdermozilla-central@1960b018c1f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1440405
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)