Bug 1390896 - Make mach wpt compatible with latest upstream, r=maja_zf
Upstream wpt changed from having a wptrun script to a wpt script with
a run subcommand. This involved some internal movement of code which
broke the `mach wpt` command when used with a non-firefox
product. This commit changes the mach integration to be compatible
with the new upstream API.
MozReview-Commit-ID: 1hvmZedNHSX
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -68,58 +68,49 @@ class WebPlatformTestsRunnerSetup(Mozbui
if kwargs["webdriver_binary"] is None:
kwargs["webdriver_binary"] = self.get_binary_path("geckodriver", validate_exists=False)
self.setup_fonts_firefox()
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')
- sys.path.insert(0, os.path.join(here, "tests", "tools"))
-
- import wptrun
-
- product = kwargs["product"]
-
- setup_func = {
- "chrome": wptrun.setup_chrome,
- "edge": wptrun.setup_edge,
- "servo": wptrun.setup_servo,
- }[product]
+ kwargs["tests_root"] = os.path.join(here, "tests")
- try:
- wptrun.check_environ(product)
-
- setup_func(wptrun.virtualenv.Virtualenv(self.virtualenv_manager.virtualenv_root),
- kwargs,
- True)
- except wptrun.WptrunError as e:
- print(e.message, file=sys.stderr)
- sys.exit(1)
-
- 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"])
if not os.path.exists(metadir):
os.makedirs(metadir)
kwargs["metadata_root"] = metadir
src_manifest = os.path.join(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:
dest.write(src.read())
- kwargs = wptcommandline.check_args(kwargs)
+ from tools.wpt import run
+
+ try:
+ kwargs = run.setup_wptrunner(run.virtualenv.Virtualenv(self.virtualenv_manager.virtualenv_root),
+ **kwargs)
+ except run.WptrunError as e:
+ print(e.message, file=sys.stderr)
+ sys.exit(1)
+
+ return kwargs
def setup_fonts_firefox(self):
# Ensure the Ahem font is available
if not sys.platform.startswith("darwin"):
font_path = os.path.join(os.path.dirname(self.get_binary_path()), "fonts")
else:
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")
--- a/testing/web-platform/mach_commands_base.py
+++ b/testing/web-platform/mach_commands_base.py
@@ -14,16 +14,16 @@ class WebPlatformTestsRunner(object):
"""Run web platform tests."""
def __init__(self, setup):
self.setup = setup
def run(self, **kwargs):
from wptrunner import wptrunner
if kwargs["product"] in ["firefox", None]:
- self.setup.kwargs_firefox(kwargs)
+ kwargs = self.setup.kwargs_firefox(kwargs)
elif kwargs["product"] in ("chrome", "edge", "servo"):
- self.setup.kwargs_wptrun(kwargs)
+ kwargs = self.setup.kwargs_wptrun(kwargs)
else:
raise ValueError("Unknown product %s" % kwargs["product"])
logger = wptrunner.setup_logging(kwargs, {self.setup.default_log_type: sys.stdout})
result = wptrunner.start(**kwargs)
return int(not result)