1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 from __future__
import unicode_literals
10 from mach_commands_base
import WebPlatformTestsRunner
, create_parser_wpt
11 from mach
.decorators
import (
16 class WebPlatformTestsRunnerSetup(object):
17 default_log_type
= "tbpl"
19 def __init__(self
, context
):
20 self
.context
= context
22 def kwargs_firefox(self
, kwargs
):
23 from wptrunner
import wptcommandline
25 if kwargs
["config"] is None:
26 kwargs
["config"] = os
.path
.join(
27 self
.context
.package_root
, "web-platform", "wptrunner.ini"
29 if kwargs
["binary"] is None:
30 kwargs
["binary"] = self
.context
.firefox_bin
31 if kwargs
["prefs_root"] is None:
32 kwargs
["prefs_root"] = os
.path
.join(
33 self
.context
.package_root
, "web-platform", "prefs"
35 if kwargs
["certutil_binary"] is None:
36 kwargs
["certutil_binary"] = os
.path
.join(self
.context
.bin_dir
, "certutil")
37 if kwargs
["stackfix_dir"] is None:
38 kwargs
["stackfix_dir"] = self
.context
.bin_dir
39 if kwargs
["ssl_type"] in (None, "pregenerated"):
40 cert_root
= os
.path
.join(
41 self
.context
.package_root
, "web-platform", "tests", "tools", "certs"
43 if kwargs
["ca_cert_path"] is None:
44 kwargs
["ca_cert_path"] = os
.path
.join(cert_root
, "cacert.pem")
45 if kwargs
["host_key_path"] is None:
46 kwargs
["host_key_path"] = os
.path
.join(
47 cert_root
, "web-platform.test.key"
49 if kwargs
["host_cert_path"] is None:
50 kwargs
["host_cert_path"] = os
.path
.join(
51 cert_root
, "web-platform.test.pem"
53 kwargs
["capture_stdio"] = True
56 kwargs
["exclude"] is None
57 and kwargs
["include"] is None
58 and not sys
.platform
.startswith("linux")
60 kwargs
["exclude"] = ["css"]
62 if kwargs
["webdriver_binary"] is None:
63 kwargs
["webdriver_binary"] = os
.path
.join(
64 self
.context
.bin_dir
, "geckodriver"
67 return wptcommandline
.check_args(kwargs
)
69 def kwargs_wptrun(self
, kwargs
):
70 raise NotImplementedError
73 @Command("web-platform-tests", category
="testing", parser
=create_parser_wpt
)
74 def run_web_platform_tests(command_context
, **kwargs
):
75 command_context
._mach
_context
.activate_mozharness_venv()
76 return WebPlatformTestsRunner(
77 WebPlatformTestsRunnerSetup(command_context
._mach
_context
)
81 @Command("wpt", category
="testing", parser
=create_parser_wpt
)
82 def run_wpt(command_context
, **params
):
83 return command_context
.run_web_platform_tests(**params
)