Bug 1500081 - Use --install-fonts to install fonts for wptrunner, r=automatedtester
authorJames Graham <james@hoppipolla.co.uk>
Thu, 18 Oct 2018 13:44:36 +0000
changeset 490291 7cf3a024e668a21da95252827dca09e193e6f3e7
parent 490290 d893e01e4d37783a8f24c2081b6e85905f3501b1
child 490292 048da8a3c95146d4d94d8a8a47d2ff723792abdf
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersautomatedtester
bugs1500081
milestone64.0a1
Bug 1500081 - Use --install-fonts to install fonts for wptrunner, r=automatedtester This replaces a previous Firefox-only method except on Windows 7 where it seems that we have some issues with the registry. Differential Revision: https://phabricator.services.mozilla.com/D9091
testing/mozharness/scripts/web_platform_tests.py
testing/web-platform/mach_commands.py
testing/web-platform/tests/tools/wptrunner/wptrunner/wptrunner.py
--- a/testing/mozharness/scripts/web_platform_tests.py
+++ b/testing/mozharness/scripts/web_platform_tests.py
@@ -228,16 +228,22 @@ class WebPlatformTest(TestingMixin, Merc
 
         if self.is_android:
             cmd += ["--device-serial=%s" % self.device_serial]
             cmd += ["--package-name=%s" % self.query_package_name()]
 
         if not sys.platform.startswith("linux"):
             cmd += ["--exclude=css"]
 
+        if mozinfo.info["os"] == "win" and mozinfo.info["os_version"] == "6.1":
+            # On Windows 7 --install-fonts fails, so fall back to a Firefox-specific codepath
+            self._install_fonts()
+        else:
+            cmd += ["--install-fonts"]
+
         for test_type in test_types:
             cmd.append("--test-type=%s" % test_type)
 
         if c['extra_prefs']:
             cmd.extend(['--setpref={}'.format(p) for p in c['extra_prefs']])
 
         if not c["e10s"]:
             cmd.append("--disable-e10s")
@@ -324,18 +330,16 @@ class WebPlatformTest(TestingMixin, Merc
         ahem_src = os.path.join(dirs["abs_wpttest_dir"], "tests", "fonts", "Ahem.ttf")
         ahem_dest = os.path.join(font_path, "Ahem.ttf")
         with open(ahem_src, "rb") as src, open(ahem_dest, "wb") as dest:
             dest.write(src.read())
 
     def run_tests(self):
         dirs = self.query_abs_dirs()
 
-        self._install_fonts()
-
         parser = StructuredOutputParser(config=self.config,
                                         log_obj=self.log_obj,
                                         log_compact=True,
                                         error_list=BaseErrorList + HarnessErrorList)
 
         env = {'MINIDUMP_SAVE_PATH': dirs['abs_blob_upload_dir']}
         env['RUST_BACKTRACE'] = 'full'
 
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -73,29 +73,35 @@ class WebPlatformTestsRunnerSetup(Mozbui
         if kwargs["log_mach_screenshot"] is None:
             kwargs["log_mach_screenshot"] = True
 
         kwargs["capture_stdio"] = True
 
         return kwargs
 
     def kwargs_firefox(self, kwargs):
+        import mozinfo
         from wptrunner import wptcommandline
         kwargs = self.kwargs_common(kwargs)
 
         if kwargs["binary"] is None:
             kwargs["binary"] = self.get_binary_path()
 
         if kwargs["certutil_binary"] is None:
             kwargs["certutil_binary"] = self.get_binary_path('certutil')
 
         if kwargs["webdriver_binary"] is None:
             kwargs["webdriver_binary"] = self.get_binary_path("geckodriver", validate_exists=False)
 
-        self.setup_fonts_firefox()
+
+        if mozinfo.info["os"] == "win" and mozinfo.info["os_version"] == "6.1":
+            # On Windows 7 --install-fonts fails, so fall back to a Firefox-specific codepath
+            self.setup_fonts_firefox()
+        else:
+            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')
@@ -136,16 +142,17 @@ class WebPlatformTestsRunnerSetup(Mozbui
             font_path = os.path.join(os.path.dirname(self.get_binary_path()), os.pardir, "Resources", "res", "fonts")
         ahem_src = os.path.join(self.topsrcdir, "testing", "web-platform", "tests", "fonts", "Ahem.ttf")
         ahem_dest = os.path.join(font_path, "Ahem.ttf")
         if not os.path.exists(ahem_dest) and os.path.exists(ahem_src):
             with open(ahem_src, "rb") as src, open(ahem_dest, "wb") as dest:
                 dest.write(src.read())
 
 
+
 class WebPlatformTestsUpdater(MozbuildObject):
     """Update web platform tests."""
     def setup_logging(self, **kwargs):
         import update
         return update.setup_logging(kwargs, {"mach": sys.stdout})
 
     def run_update(self, logger, **kwargs):
         import update
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptrunner.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptrunner.py
@@ -145,17 +145,17 @@ def run_tests(config, test_paths, produc
 
         env_extras = get_env_extras(**kwargs)
 
         check_args(**kwargs)
 
         if kwargs["install_fonts"]:
             env_extras.append(FontInstaller(
                 font_dir=kwargs["font_dir"],
-                ahem=os.path.join(kwargs["tests_root"], "fonts/Ahem.ttf")
+                ahem=os.path.join(test_paths["/"]["tests_path"], "fonts/Ahem.ttf")
             ))
 
         run_info, test_loader = get_loader(test_paths,
                                            product,
                                            run_info_extras=run_info_extras(**kwargs),
                                            **kwargs)
 
         test_source_kwargs = {"processes": kwargs["processes"]}