Debian Codegraph @

testing/web-platform/mach_test_package_commands.py

raw
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/.
4
5 import os
6 import sys
7
8 from mach.decorators import Command
9 from mach_commands_base import WebPlatformTestsRunner, create_parser_wpt
10
11
12 class WebPlatformTestsRunnerSetup:
13 default_log_type = "tbpl"
14
15 def __init__(self, context):
16 self.context = context
17
18 def kwargs_firefox(self, kwargs):
19 from wptrunner import wptcommandline
20
21 if kwargs["config"] is None:
22 kwargs["config"] = os.path.join(
23 self.context.package_root, "web-platform", "wptrunner.ini"
24 )
25 if kwargs["binary"] is None:
26 kwargs["binary"] = self.context.firefox_bin
27 if kwargs["prefs_root"] is None:
28 kwargs["prefs_root"] = os.path.join(
29 self.context.package_root, "web-platform", "prefs"
30 )
31 if kwargs["certutil_binary"] is None:
32 kwargs["certutil_binary"] = os.path.join(self.context.bin_dir, "certutil")
33 if kwargs["stackfix_dir"] is None:
34 kwargs["stackfix_dir"] = self.context.bin_dir
35 if kwargs["ssl_type"] in (None, "pregenerated"):
36 cert_root = os.path.join(
37 self.context.package_root, "web-platform", "tests", "tools", "certs"
38 )
39 if kwargs["ca_cert_path"] is None:
40 kwargs["ca_cert_path"] = os.path.join(cert_root, "cacert.pem")
41 if kwargs["host_key_path"] is None:
42 kwargs["host_key_path"] = os.path.join(
43 cert_root, "web-platform.test.key"
44 )
45 if kwargs["host_cert_path"] is None:
46 kwargs["host_cert_path"] = os.path.join(
47 cert_root, "web-platform.test.pem"
48 )
49 kwargs["capture_stdio"] = True
50
51 if (
52 kwargs["exclude"] is None
53 and kwargs["include"] is None
54 and not sys.platform.startswith("linux")
55 ):
56 kwargs["exclude"] = ["css"]
57
58 if kwargs["webdriver_binary"] is None:
59 kwargs["webdriver_binary"] = os.path.join(
60 self.context.bin_dir, "geckodriver"
61 )
62
63 return wptcommandline.check_args(kwargs)
64
65 def kwargs_wptrun(self, kwargs):
66 raise NotImplementedError
67
68
69 @Command("web-platform-tests", category="testing", parser=create_parser_wpt)
70 def run_web_platform_tests(command_context, **kwargs):
71 command_context._mach_context.activate_mozharness_venv()
72 return WebPlatformTestsRunner(
73 WebPlatformTestsRunnerSetup(command_context._mach_context)
74 ).run(**kwargs)
75
76
77 @Command("wpt", category="testing", parser=create_parser_wpt)
78 def run_wpt(command_context, **params):
79 return command_context.run_web_platform_tests(**params)