Skip to content

Commit

Permalink
Bug 1367041 - Add |mach wpt| support for Chrome, Edge and Servo, r=Au…
Browse files Browse the repository at this point in the history
…tomatedTester

Using the wptrun infrastructure from upstream, it is now posible to
make it easy to run web-platform-tests in other browsers. The syntax
used is

mach wpt --product [chrome|servo|edge] [tests]

This will try to use the selected product; possibly prompting to
install dependencies like the WebDriver implementation. For servo if
the install isn't on the PATH then --binary can be used to point to
the actual location.

Because manifest metadata is kept in the same directory as expectation
data and we don't want to reuse Firefox expectation data for other
browsers, a new products subdirectory is introduced and added to the
ignore files. This will contain a subdirectory for each product into
which a copy of the test manifest is placed. It may also be used to
store any expectation data for the other products, in the same way as
testing/web-platform/meta.

MozReview-Commit-ID: 8fdCnha5t2F
  • Loading branch information
jgraham committed May 31, 2017
1 parent cf7bfa3 commit b70a42d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ GPATH
# Git clone directory for updating web-platform-tests
testing/web-platform/sync/

# Third party metadata for web-platform-tests
testing/web-platform/products/

# Android Gradle artifacts.
mobile/android/gradle/.gradle

Expand Down
3 changes: 3 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ GPATH
# Git clone directory for updating web-platform-tests
^testing/web-platform/sync/

# Third party metadata for web-platform-tests
^testing/web-platform/products/

# Android Gradle artifacts.
^mobile/android/gradle/.gradle

Expand Down
49 changes: 9 additions & 40 deletions testing/web-platform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,45 +235,14 @@ Running Tests In Other Browsers

web-platform-tests is cross browser, and the runner is compatible with
multiple browsers. Therefore it's possible to check the behaviour of
tests in other browsers. This is somewhat more involved than running
them in Firefox since extra dependencies may be required. For example
to test in Chrome:
tests in other browsers. By default Chrome, Edge and Servo are
supported. In order to run the tests in these browsers use the
`--product` argument to wptrunner:

1. Download the chromedriver binary and place it somewhere sensible
e.g. `~/bin`
mach wpt --product chrome dom/historical.html

2. In your gecko source tree activate the virtualenv created by mach,
since this has most dependencies already installed. This is typically
in objdir/_virtualenv and is activated via e.g.

source objdir/_virtualenv/bin/activate

3. Install the extra requirements:

cd testing/web-platform/harness
pip install -r requirements_chrome.txt

4. Edit the config file `testing/web-platform/wptrunner.ini` so that
Chrome support is enabled by changing the section that reads:

[products]
firefox =

to read

[products]
firefox =
chrome =

(alternatively create a new config file elsewhere and use the
`--config` option to `runtests.py` to point wptrunner at this config
file).

5. Run `runtests.py` using the location of chromedriver as
the binary:

cd testing/web-platform
python runtests.py --product=chrome --binary=~/bin/chromedriver --log-mach=-

By default this will use the same test checkout and metadata as are in
the Gecko tree, so it's easy to compare behaviour relative to Firefox.
By default these browsers run without expectation metadata, but it can
be added in the `testing/web-platform/products/<product>`
directory. To run with the same metadata as for Firefox (so that
differences are reported as unexpected results), pass `--meta
testing/web-platform/meta` to the mach command.
46 changes: 43 additions & 3 deletions testing/web-platform/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class InvalidTestPathError(Exception):
class WebPlatformTestsRunner(MozbuildObject):
"""Run web platform tests."""

def setup_kwargs(self, kwargs):
def setup_kwargs_firefox(self, kwargs):
from wptrunner import wptcommandline

build_path = os.path.join(self.topobjdir, 'build')
Expand Down Expand Up @@ -67,10 +67,50 @@ def setup_kwargs(self, kwargs):

kwargs = wptcommandline.check_args(kwargs)

def setup_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

setup_func = {
"chrome": wptrun.setup_chrome,
"edge": wptrun.setup_edge,
"servo": wptrun.setup_servo,
}[kwargs["product"]]

setup_func(wptrun.virtualenv.Virtualenv(self.virtualenv_manager.virtualenv_root),
kwargs,
True)

kwargs["tests_root"] = os.path.join(here, "tests")

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)

def run_tests(self, **kwargs):
from wptrunner import wptrunner

self.setup_kwargs(kwargs)
if kwargs["product"] in ["firefox", None]:
self.setup_kwargs_firefox(kwargs)
elif kwargs["product"] in ("chrome", "edge", "servo"):
self.setup_kwargs_wptrun(kwargs)
else:
raise ValueError("Unknown product %s" % kwargs["product"])

logger = wptrunner.setup_logging(kwargs, {"mach": sys.stdout})
result = wptrunner.run_tests(**kwargs)
Expand Down Expand Up @@ -258,7 +298,7 @@ def run_update(self, check_clean=False, **kwargs):

def create_parser_wpt():
from wptrunner import wptcommandline
return wptcommandline.create_parser(["firefox"])
return wptcommandline.create_parser(["firefox", "chrome", "edge", "servo"])

def create_parser_update():
from update import updatecommandline
Expand Down
3 changes: 3 additions & 0 deletions testing/web-platform/products/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory is for storing metadata files when running
web-platform-tests with non-firefox browsers. By default all
subdirectories here are ignored in VCS.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ mozprofile >= 0.21
mozprocess >= 0.19
mozcrash >= 0.13
mozrunner >= 6.7
mozleak >= 0.1
3 changes: 3 additions & 0 deletions testing/web-platform/wptrunner.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[products]
firefox =
chrome =
edge =
servo =

[web-platform-tests]
remote_url = https://github.com/w3c/web-platform-tests.git
Expand Down

0 comments on commit b70a42d

Please sign in to comment.