Bug 1511335 - Fix logging setup for ./mach wpt --product, r=ahal
authorJames Graham <james@hoppipolla.co.uk>
Tue, 04 Dec 2018 21:53:27 +0000
changeset 508565 bf12a43a4100cc07d31447e4b148a7f27af5e6e2
parent 508564 d808b528532ac7ccb48bbcb7447f194a822381e5
child 508566 e134df617e0c7b95649dfc315a5ce537e9ca3fe4
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1511335 - Fix logging setup for ./mach wpt --product, r=ahal When running non-Firefox products in wpt we go through the run.py script from upstream. Therefore we need to initialise the logger in that module as well as the one in wptrunner now that it's been properly converted to use logging rather than print statements. In addition, we change the run.py module to allow passing in logging defaults for the case where nothing is specified on the command line since the behaviour for wpt upstream is different to the behaviour for gecko. Differential Revision: https://phabricator.services.mozilla.com/D13547
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -21,23 +21,27 @@ from mach.decorators import (
 from mach_commands_base import WebPlatformTestsRunner, create_parser_wpt
 class WebPlatformTestsRunnerSetup(MozbuildObject):
     default_log_type = "mach"
-    def kwargs_common(self, kwargs):
+    def __init__(self, *args, **kwargs):
+        super(WebPlatformTestsRunnerSetup, self).__init__(*args, **kwargs)
+        self._here = os.path.join(self.topsrcdir, 'testing', 'web-platform')
+        kwargs["tests_root"] = os.path.join(self._here, "tests")
+        sys.path.insert(0, kwargs["tests_root"])
         build_path = os.path.join(self.topobjdir, 'build')
-        here = os.path.split(__file__)[0]
-        tests_src_path = os.path.join(here, "tests")
         if build_path not in sys.path:
+    def kwargs_common(self, kwargs):
+        tests_src_path = os.path.join(self._here, "tests")
         if kwargs["product"] == "fennec":
             # package_name may be non-fennec in the future
             package_name = kwargs["package_name"]
             if not package_name:
                 package_name = self.substs["ANDROID_PACKAGE_NAME"]
             # Note that this import may fail in non-fennec trees
             from mozrunner.devices.android_device import verify_android_device, grant_runtime_permissions
@@ -102,29 +106,24 @@ class WebPlatformTestsRunnerSetup(Mozbui
             kwargs["install_fonts"] = True
         kwargs = wptcommandline.check_args(kwargs)
         return kwargs
     def kwargs_wptrun(self, kwargs):
         from wptrunner import wptcommandline
-        here = os.path.join(self.topsrcdir, 'testing', 'web-platform')
-        kwargs["tests_root"] = os.path.join(here, "tests")
-        sys.path.insert(0, kwargs["tests_root"])
         if kwargs["metadata_root"] is None:
-            metadir = os.path.join(here, "products", kwargs["product"])
+            metadir = os.path.join(self._here, "products", kwargs["product"])
             if not os.path.exists(metadir):
             kwargs["metadata_root"] = metadir
-        src_manifest = os.path.join(here, "meta", "MANIFEST.json")
+        src_manifest = os.path.join(self._here, "meta", "MANIFEST.json")
         dest_manifest = os.path.join(kwargs["metadata_root"], "MANIFEST.json")
         if not os.path.exists(dest_manifest) and os.path.exists(src_manifest):
             with open(src_manifest) as src, open(dest_manifest, "w") as dest:
         from tools.wpt import run
--- a/testing/web-platform/mach_commands_base.py
+++ b/testing/web-platform/mach_commands_base.py
@@ -1,29 +1,30 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import os
 import sys
 def create_parser_wpt():
     from wptrunner import wptcommandline
     return wptcommandline.create_parser(["fennec", "firefox", "chrome", "edge", "servo"])
 class WebPlatformTestsRunner(object):
     """Run web platform tests."""
     def __init__(self, setup):
         self.setup = setup
     def setup_logging(self, **kwargs):
-        from wptrunner import wptrunner
-        return wptrunner.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout})
+        from tools.wpt import run
+        return run.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout})
     def run(self, logger, **kwargs):
         from wptrunner import wptrunner
         if kwargs["manifest_update"] is not False:
         kwargs["manifest_update"] = False
--- a/testing/web-platform/tests/tools/wpt/run.py
+++ b/testing/web-platform/tests/tools/wpt/run.py
@@ -455,28 +455,30 @@ product_setup = {
     "servo": Servo,
     "servodriver": ServoWebDriver,
     "sauce": Sauce,
     "opera": Opera,
     "webkit": WebKit,
-def setup_logging(kwargs):
+def setup_logging(kwargs, default_config=None):
     import mozlog
     from wptrunner import wptrunner
     global logger
     # Use the grouped formatter by default where mozlog 3.9+ is installed
-    if hasattr(mozlog.formatters, "GroupingFormatter"):
-        default_formatter = "grouped"
-    else:
-        default_formatter = "mach"
-    wptrunner.setup_logging(kwargs, {default_formatter: sys.stdout})
+    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)
     logger = wptrunner.logger
 def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs):
     from wptrunner import wptcommandline
     kwargs = utils.Kwargs(kwargs.iteritems())