Bug 1583603 - Set formatter defaults correctly for mozlog, r=maja_zf
authorJames Graham <james@hoppipolla.co.uk>
Wed, 25 Sep 2019 19:37:38 +0000
changeset 494973 ed5efc0182326c0a131b71cd150da351d5b4d400
parent 494972 7914ef375e3c8fb2c6148b97decff55594a27f54
child 494974 371641b1010b834f4144fdb8688a511c381a6776
push id114131
push userdluca@mozilla.com
push dateThu, 26 Sep 2019 09:47:34 +0000
treeherdermozilla-inbound@1dc1a755079a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1583603
milestone71.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 1583603 - Set formatter defaults correctly for mozlog, r=maja_zf Gecko was trying to pass formatter options in by default, which doesn't work if the user overrides the formatter. Instead pass in the default options explicitly using the designed mechanism, which previously wasn't exposed in wpt. Differential Revision: https://phabricator.services.mozilla.com/D47117
testing/web-platform/mach_commands.py
testing/web-platform/mach_commands_base.py
testing/web-platform/tests/tools/wpt/run.py
testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -291,19 +291,16 @@ class MachCommands(MachCommandBase):
             import mozdebug
             if not mozdebug.get_debugger_info(params.get('debugger')):
                 sys.exit(1)
 
         wpt_setup = self._spawn(WebPlatformTestsRunnerSetup)
         wpt_setup._mach_context = self._mach_context
         wpt_runner = WebPlatformTestsRunner(wpt_setup)
 
-        if params["log_mach_screenshot"] is None:
-            params["log_mach_screenshot"] = True
-
         logger = wpt_runner.setup_logging(**params)
 
         if conditions.is_android(self) and params["product"] != "firefox_android":
             logger.warning("Must specify --product=firefox_android in Android environment.")
 
         return wpt_runner.run(logger, **params)
 
     @Command("wpt",
--- a/testing/web-platform/mach_commands_base.py
+++ b/testing/web-platform/mach_commands_base.py
@@ -14,17 +14,18 @@ def create_parser_wpt():
 class WebPlatformTestsRunner(object):
     """Run web platform tests."""
 
     def __init__(self, setup):
         self.setup = setup
 
     def setup_logging(self, **kwargs):
         from tools.wpt import run
-        return run.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout})
+        return run.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout},
+                                 formatter_defaults={"screenshot": True})
 
     def run(self, logger, **kwargs):
         from wptrunner import wptrunner
 
         if kwargs["manifest_update"] is not False:
             self.update_manifest(logger)
         kwargs["manifest_update"] = False
 
--- a/testing/web-platform/tests/tools/wpt/run.py
+++ b/testing/web-platform/tests/tools/wpt/run.py
@@ -622,30 +622,30 @@ product_setup = {
     "servodriver": ServoWebDriver,
     "sauce": Sauce,
     "opera": Opera,
     "webkit": WebKit,
     "epiphany": Epiphany,
 }
 
 
-def setup_logging(kwargs, default_config=None):
+def setup_logging(kwargs, default_config=None, formatter_defaults=None):
     import mozlog
     from wptrunner import wptrunner
 
     global logger
 
     # Use the grouped formatter by default where mozlog 3.9+ is installed
     if default_config is None:
         if hasattr(mozlog.formatters, "GroupingFormatter"):
             default_formatter = "grouped"
         else:
             default_formatter = "mach"
         default_config = {default_formatter: sys.stdout}
-    wptrunner.setup_logging(kwargs, default_config)
+    wptrunner.setup_logging(kwargs, default_config, formatter_defaults=formatter_defaults)
     logger = wptrunner.logger
     return logger
 
 
 def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs):
     from wptrunner import wptcommandline
 
     kwargs = utils.Kwargs(kwargs.iteritems())
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptlogging.py
@@ -1,21 +1,22 @@
 import logging
 
 from mozlog import commandline, stdadapter, set_default_logger
 from mozlog.structuredlog import StructuredLogger, log_levels
 
 
-def setup(args, defaults):
+def setup(args, defaults, formatter_defaults=None):
     logger = args.pop('log', None)
     if logger:
         set_default_logger(logger)
         StructuredLogger._logger_states["web-platform-tests"] = logger._state
     else:
-        logger = commandline.setup_logging("web-platform-tests", args, defaults)
+        logger = commandline.setup_logging("web-platform-tests", args, defaults,
+                                           formatter_defaults=formatter_defaults)
     setup_stdlib_logger()
 
     for name in args.keys():
         if name.startswith("log_"):
             args.pop(name)
 
     return logger