forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_wpt_tests.py
executable file
·168 lines (142 loc) · 6.74 KB
/
run_wpt_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env vpython3
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Runs WPT as an isolate bundle.
This script maps flags supported by run_isolate_script_test.py to flags that are
understood by WPT.
Here's the mapping [isolate script flag] : [wpt flag]
--isolated-script-test-output : --log-chromium
--total-shards : --total-chunks
--shard-index : -- this-chunk
"""
import json
import os
import shutil
import sys
import common
import wpt_common
SRC_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
WEB_TESTS_DIR = os.path.join(SRC_DIR, "third_party", "blink", "web_tests")
# OUT_DIR is a format string that will later be substituted into for the
# specific output directory.
OUT_DIR = os.path.join(SRC_DIR, "out", "{}")
# The checked-in manifest is copied to a temporary working directory so it can
# be mutated by wptrunner
WPT_CHECKED_IN_MANIFEST = os.path.join(
WEB_TESTS_DIR, "external", "WPT_BASE_MANIFEST_8.json")
WPT_WORKING_COPY_MANIFEST = os.path.join(OUT_DIR, "MANIFEST.json")
WPT_CHECKED_IN_METADATA_DIR = os.path.join(WEB_TESTS_DIR, "external", "wpt")
WPT_METADATA_OUTPUT_DIR = os.path.join(OUT_DIR, "wpt_expectations_metadata")
WPT_OVERRIDE_EXPECTATIONS_PATH = os.path.join(
WEB_TESTS_DIR, "WPTOverrideExpectations")
CHROME_BINARY = os.path.join(OUT_DIR, "chrome")
CHROME_BINARY_MAC = os.path.join(
OUT_DIR, "Chromium.app", "Contents", "MacOS", "Chromium")
CHROMEDRIVER_BINARY = os.path.join(OUT_DIR, "chromedriver")
MOJO_JS_PATH = os.path.join(OUT_DIR, "gen")
TESTS_ROOT_DIR = os.path.join(WEB_TESTS_DIR, "external", "wpt")
WPT_BINARY = os.path.join(SRC_DIR, "third_party", "wpt_tools", "wpt", "wpt")
class WPTTestAdapter(wpt_common.BaseWptScriptAdapter):
@property
def rest_args(self):
rest_args = super(WPTTestAdapter, self).rest_args
# Update the output directory to the default if it's not set.
self.maybe_set_default_isolated_script_test_output()
chrome = CHROME_BINARY.format(self.options.target)
chromedriver = CHROMEDRIVER_BINARY.format(self.options.target)
if self.port.host.platform.is_win():
chrome = "%s.exe" % chrome
chromedriver = "%s.exe" % chromedriver
elif self.port.host.platform.is_mac():
chrome = CHROME_BINARY_MAC.format(self.options.target)
# Here we add all of the arguments required to run WPT tests on Chrome.
rest_args.extend([
WPT_BINARY,
"--venv=" + SRC_DIR,
"--skip-venv-setup",
"run",
"chrome"
] + self.options.test_list + [
"--binary=" + chrome,
"--binary-arg=--host-resolver-rules="
"MAP nonexistent.*.test ~NOTFOUND, MAP *.test 127.0.0.1",
"--binary-arg=--enable-experimental-web-platform-features",
"--binary-arg=--enable-blink-test-features",
"--binary-arg=--enable-blink-features=MojoJS,MojoJSTest",
"--binary-arg=--disable-field-trial-config",
"--webdriver-binary=" + chromedriver,
"--webdriver-arg=--enable-chrome-logs",
"--headless",
"--no-capture-stdio",
"--no-manifest-download",
"--no-pause-after-test",
# Exclude webdriver tests for now. They are run separately on the CI
"--exclude=webdriver",
"--exclude=infrastructure/webdriver",
# By default, WPT will treat unexpected passes as errors, so we
# disable that to be consistent with Chromium CI.
"--no-fail-on-unexpected-pass",
"--metadata", WPT_METADATA_OUTPUT_DIR.format(self.options.target),
# By specifying metadata above, WPT will try to find manifest in the
# metadata directory. So here we point it back to the correct path
# for the manifest.
# TODO(lpz): Allowing WPT to rebuild its own manifest temporarily to
# gauge performance impact. Issue with specifying the base manifest
# below is that it can get stale if tests are renamed, and requires
# a lengthy import/export cycle to refresh. So we allow WPT to
# update the manifest in cast it's stale.
#"--no-manifest-update",
"--manifest", WPT_WORKING_COPY_MANIFEST.format(self.options.target),
# (crbug.com/1023835) The flags below are temporary to aid debugging
"--log-mach=-",
"--log-mach-verbose",
# See if multi-processing affects timeouts.
# TODO(lpz): Consider removing --processes and compute automatically
# from multiprocessing.cpu_count()
"--processes=" + self.options.child_processes,
"--mojojs-path=" + MOJO_JS_PATH.format(self.options.target),
"--tests=" + TESTS_ROOT_DIR,
])
return rest_args
def add_extra_arguments(self, parser):
target_help = "Specify the target build subdirectory under src/out/"
parser.add_argument("-t", "--target", dest="target", default="Release",
help=target_help)
child_processes_help = "Number of drivers to run in parallel"
parser.add_argument("-j", "--child-processes", dest="child_processes",
default="1", help=child_processes_help)
parser.add_argument("test_list", nargs="*",
help="List of tests or test directories to run")
def do_pre_test_run_tasks(self):
# Copy the checked-in manifest to the temporary working directory
shutil.copy(WPT_CHECKED_IN_MANIFEST,
WPT_WORKING_COPY_MANIFEST.format(self.options.target))
# Generate WPT metadata files.
common.run_command([
sys.executable,
os.path.join(wpt_common.BLINK_TOOLS_DIR, 'build_wpt_metadata.py'),
"--metadata-output-dir",
WPT_METADATA_OUTPUT_DIR.format(self.options.target),
"--additional-expectations",
WPT_OVERRIDE_EXPECTATIONS_PATH,
"--checked-in-metadata-dir",
WPT_CHECKED_IN_METADATA_DIR,
"--no-process-baselines",
])
def main():
adapter = WPTTestAdapter()
return adapter.run_test()
# This is not really a "script test" so does not need to manually add
# any additional compile targets.
def main_compile_targets(args):
json.dump([], args.output)
if __name__ == '__main__':
# Conform minimally to the protocol defined by ScriptTest.
if 'compile_targets' in sys.argv:
funcs = {
'run': None,
'compile_targets': main_compile_targets,
}
sys.exit(common.run_script(sys.argv[1:], funcs))
sys.exit(main())