moztest 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- moztest/__init__.py +7 -0
- moztest/adapters/__init__.py +7 -0
- moztest/adapters/unit.py +229 -0
- moztest/assertions.py +250 -0
- moztest/outcome.py +37 -0
- moztest/resolve.py +1574 -0
- moztest/results.py +365 -0
- moztest/selftest/__init__.py +0 -0
- moztest/selftest/fixtures.py +116 -0
- moztest/selftest/output.py +51 -0
- moztest/tsan.py +160 -0
- moztest/ubsan.py +195 -0
- moztest-1.2.0.dist-info/METADATA +26 -0
- moztest-1.2.0.dist-info/RECORD +16 -0
- moztest-1.2.0.dist-info/WHEEL +5 -0
- moztest-1.2.0.dist-info/top_level.txt +1 -0
moztest/resolve.py
ADDED
|
@@ -0,0 +1,1574 @@
|
|
|
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 fnmatch
|
|
6
|
+
import os
|
|
7
|
+
import pickle
|
|
8
|
+
import re
|
|
9
|
+
import sys
|
|
10
|
+
from abc import ABCMeta, abstractmethod
|
|
11
|
+
from collections import defaultdict
|
|
12
|
+
from functools import cache
|
|
13
|
+
|
|
14
|
+
import mozpack.path as mozpath
|
|
15
|
+
from manifestparser import TestManifest, combine_fields
|
|
16
|
+
from manifestparser.filters import chunk_by_runtime
|
|
17
|
+
from mozbuild.base import MozbuildObject
|
|
18
|
+
from mozbuild.testing import REFTEST_FLAVORS, TEST_MANIFESTS, install_test_files
|
|
19
|
+
from mozpack.files import FileFinder
|
|
20
|
+
|
|
21
|
+
here = os.path.abspath(os.path.dirname(__file__))
|
|
22
|
+
|
|
23
|
+
MOCHITEST_CHUNK_BY_DIR = 4
|
|
24
|
+
MOCHITEST_TOTAL_CHUNKS = 5
|
|
25
|
+
|
|
26
|
+
ROOT_TAGS_RE = re.compile(rb"^tags *:", re.MULTILINE)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def WebglSuite(name):
|
|
30
|
+
return {
|
|
31
|
+
"aliases": (name,),
|
|
32
|
+
"build_flavor": "mochitest",
|
|
33
|
+
"mach_command": "mochitest",
|
|
34
|
+
"kwargs": {"flavor": "plain", "subsuite": name, "test_paths": None},
|
|
35
|
+
"task_regex": [
|
|
36
|
+
"mochitest-" + name + "($|.*(-1|[^0-9])$)",
|
|
37
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
38
|
+
],
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
TEST_SUITES = {
|
|
43
|
+
"cppunittest": {
|
|
44
|
+
"aliases": ("cpp",),
|
|
45
|
+
"mach_command": "cppunittest",
|
|
46
|
+
"kwargs": {"test_files": None},
|
|
47
|
+
},
|
|
48
|
+
"crashtest": {
|
|
49
|
+
"aliases": ("c", "rc"),
|
|
50
|
+
"build_flavor": "crashtest",
|
|
51
|
+
"mach_command": "crashtest",
|
|
52
|
+
"kwargs": {"test_file": None},
|
|
53
|
+
"task_regex": ["crashtest($|.*(-1|[^0-9])$)", "test-verify($|.*(-1|[^0-9])$)"],
|
|
54
|
+
},
|
|
55
|
+
"crashtest-qr": {
|
|
56
|
+
"aliases": ("c", "rc"),
|
|
57
|
+
"build_flavor": "crashtest",
|
|
58
|
+
"mach_command": "crashtest",
|
|
59
|
+
"kwargs": {"test_file": None},
|
|
60
|
+
"task_regex": [
|
|
61
|
+
"crashtest-qr($|.*(-1|[^0-9])$)",
|
|
62
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
"firefox-ui-functional": {
|
|
66
|
+
"aliases": ("fxfn",),
|
|
67
|
+
"mach_command": "firefox-ui-functional",
|
|
68
|
+
"kwargs": {},
|
|
69
|
+
},
|
|
70
|
+
"firefox-ui-update": {
|
|
71
|
+
"aliases": ("fxup",),
|
|
72
|
+
"mach_command": "firefox-ui-update",
|
|
73
|
+
"kwargs": {},
|
|
74
|
+
},
|
|
75
|
+
"marionette-integration": {
|
|
76
|
+
"aliases": ("mn",),
|
|
77
|
+
"build_flavor": "marionette",
|
|
78
|
+
"mach_command": "marionette-test",
|
|
79
|
+
"kwargs": {"tests": None, "subsuite": "integration"},
|
|
80
|
+
"task_regex": ["marionette($|.*(-1|[^0-9])$)"],
|
|
81
|
+
},
|
|
82
|
+
"marionette-unittest": {
|
|
83
|
+
"aliases": ("mnself",),
|
|
84
|
+
"build_flavor": "marionette",
|
|
85
|
+
"mach_command": "marionette-test",
|
|
86
|
+
"kwargs": {"tests": None, "subsuite": "unittest"},
|
|
87
|
+
"task_regex": ["marionette($|.*(-1|[^0-9])$)"],
|
|
88
|
+
},
|
|
89
|
+
"mochitest-a11y": {
|
|
90
|
+
"aliases": ("a11y", "ally"),
|
|
91
|
+
"build_flavor": "a11y",
|
|
92
|
+
"mach_command": "mochitest",
|
|
93
|
+
"kwargs": {
|
|
94
|
+
"flavor": "a11y",
|
|
95
|
+
"test_paths": None,
|
|
96
|
+
"e10s": False,
|
|
97
|
+
"enable_fission": False,
|
|
98
|
+
},
|
|
99
|
+
"task_regex": [
|
|
100
|
+
"mochitest-a11y($|.*(-1|[^0-9])$)",
|
|
101
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
"mochitest-browser-chrome": {
|
|
105
|
+
"aliases": ("bc", "browser"),
|
|
106
|
+
"build_flavor": "browser-chrome",
|
|
107
|
+
"mach_command": "mochitest",
|
|
108
|
+
"kwargs": {"flavor": "browser-chrome", "test_paths": None},
|
|
109
|
+
"task_regex": [
|
|
110
|
+
"mochitest-browser-chrome($|.*(-1|[^0-9])$)",
|
|
111
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
"mochitest-browser-chrome-thunderbird": {
|
|
115
|
+
"aliases": ("bct",),
|
|
116
|
+
"build_flavor": "browser-chrome",
|
|
117
|
+
"mach_command": "mochitest",
|
|
118
|
+
"kwargs": {
|
|
119
|
+
"flavor": "browser-chrome",
|
|
120
|
+
"subsuite": "thunderbird",
|
|
121
|
+
"test_paths": None,
|
|
122
|
+
},
|
|
123
|
+
"task_regex": [
|
|
124
|
+
"mochitest-browser-chrome-thunderbird($|.*(-1|[^0-9])$)",
|
|
125
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
"mochitest-browser-chrome-thunderbird-a11y": {
|
|
129
|
+
"aliases": ("bct",),
|
|
130
|
+
"build_flavor": "browser-chrome",
|
|
131
|
+
"mach_command": "mochitest",
|
|
132
|
+
"kwargs": {
|
|
133
|
+
"flavor": "browser-chrome",
|
|
134
|
+
"subsuite": "thunderbird",
|
|
135
|
+
"test_paths": None,
|
|
136
|
+
},
|
|
137
|
+
"task_regex": [
|
|
138
|
+
"mochitest-browser-chrome-thunderbird-a11y($|.*(-1|[^0-9])$)",
|
|
139
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
"mochitest-browser-screenshots": {
|
|
143
|
+
"aliases": ("ss", "screenshots-chrome"),
|
|
144
|
+
"build_flavor": "browser-chrome",
|
|
145
|
+
"mach_command": "mochitest",
|
|
146
|
+
"kwargs": {
|
|
147
|
+
"flavor": "browser-chrome",
|
|
148
|
+
"subsuite": "screenshots",
|
|
149
|
+
"test_paths": None,
|
|
150
|
+
},
|
|
151
|
+
"task_regex": ["mochitest-browser-screenshots($|.*(-1|[^0-9])$)"],
|
|
152
|
+
},
|
|
153
|
+
"mochitest-chrome": {
|
|
154
|
+
"aliases": ("mc",),
|
|
155
|
+
"build_flavor": "chrome",
|
|
156
|
+
"mach_command": "mochitest",
|
|
157
|
+
"kwargs": {
|
|
158
|
+
"flavor": "chrome",
|
|
159
|
+
"test_paths": None,
|
|
160
|
+
"e10s": False,
|
|
161
|
+
"enable_fission": False,
|
|
162
|
+
},
|
|
163
|
+
"task_regex": [
|
|
164
|
+
"mochitest-chrome($|.*(-1|[^0-9])$)",
|
|
165
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
"mochitest-chrome-gpu": {
|
|
169
|
+
"aliases": ("gpu",),
|
|
170
|
+
"build_flavor": "chrome",
|
|
171
|
+
"mach_command": "mochitest",
|
|
172
|
+
"kwargs": {
|
|
173
|
+
"flavor": "chrome",
|
|
174
|
+
"subsuite": "gpu",
|
|
175
|
+
"test_paths": None,
|
|
176
|
+
"e10s": False,
|
|
177
|
+
"enable_fission": False,
|
|
178
|
+
},
|
|
179
|
+
"task_regex": [
|
|
180
|
+
"mochitest-gpu($|.*(-1|[^0-9])$)",
|
|
181
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
"mochitest-devtools-chrome": {
|
|
185
|
+
"aliases": ("dt", "devtools"),
|
|
186
|
+
"build_flavor": "browser-chrome",
|
|
187
|
+
"mach_command": "mochitest",
|
|
188
|
+
"kwargs": {
|
|
189
|
+
"flavor": "browser-chrome",
|
|
190
|
+
"subsuite": "devtools",
|
|
191
|
+
"test_paths": None,
|
|
192
|
+
},
|
|
193
|
+
"task_regex": [
|
|
194
|
+
"mochitest-devtools-chrome($|.*(-1|[^0-9])$)",
|
|
195
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
196
|
+
],
|
|
197
|
+
},
|
|
198
|
+
"mochitest-devtools-compat": {
|
|
199
|
+
"aliases": ("dtbc", "devtools-compat"),
|
|
200
|
+
"build_flavor": "browser-chrome",
|
|
201
|
+
"mach_command": "mochitest",
|
|
202
|
+
"kwargs": {
|
|
203
|
+
"flavor": "browser-chrome",
|
|
204
|
+
"subsuite": "devtools-compat",
|
|
205
|
+
"test_paths": None,
|
|
206
|
+
},
|
|
207
|
+
"task_regex": [
|
|
208
|
+
"devtools-compat($|.*(-1|[^0-9])$)",
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
"mochitest-browser-a11y": {
|
|
212
|
+
"aliases": ("ba", "browser-a11y"),
|
|
213
|
+
"build_flavor": "browser-chrome",
|
|
214
|
+
"mach_command": "mochitest",
|
|
215
|
+
"kwargs": {
|
|
216
|
+
"flavor": "browser-chrome",
|
|
217
|
+
"subsuite": "a11y",
|
|
218
|
+
"test_paths": None,
|
|
219
|
+
},
|
|
220
|
+
"task_regex": [
|
|
221
|
+
"mochitest-browser-a11y($|.*(-1|[^0-9])$)",
|
|
222
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
"mochitest-media": {
|
|
226
|
+
"aliases": ("mpm", "plain-media"),
|
|
227
|
+
"build_flavor": "mochitest",
|
|
228
|
+
"mach_command": "mochitest",
|
|
229
|
+
"kwargs": {"flavor": "plain", "subsuite": "media", "test_paths": None},
|
|
230
|
+
"task_regex": [
|
|
231
|
+
"mochitest-media($|.*(-1|[^0-9])$)",
|
|
232
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
"mochitest-speech-recognition": {
|
|
236
|
+
"aliases": ("msr", "speech-recognition"),
|
|
237
|
+
"build_flavor": "mochitest",
|
|
238
|
+
"mach_command": "mochitest",
|
|
239
|
+
"kwargs": {
|
|
240
|
+
"flavor": "plain",
|
|
241
|
+
"subsuite": "speech-recognition",
|
|
242
|
+
"test_paths": None,
|
|
243
|
+
},
|
|
244
|
+
"task_regex": [
|
|
245
|
+
"mochitest-speech-recognition($|.*(-1|[^0-9])$)",
|
|
246
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
"mochitest-browser-media": {
|
|
250
|
+
"aliases": ("bmda", "browser-mda"),
|
|
251
|
+
"build_flavor": "browser-chrome",
|
|
252
|
+
"mach_command": "mochitest",
|
|
253
|
+
"kwargs": {
|
|
254
|
+
"flavor": "browser-chrome",
|
|
255
|
+
"subsuite": "media-bc",
|
|
256
|
+
"test_paths": None,
|
|
257
|
+
},
|
|
258
|
+
"task_regex": [
|
|
259
|
+
"mochitest-browser-media($|.*(-1|[^0-9])$)",
|
|
260
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
"mochitest-browser-translations": {
|
|
264
|
+
"aliases": ("btr8ns", "browser-tr8ns"),
|
|
265
|
+
"build_flavor": "browser-chrome",
|
|
266
|
+
"mach_command": "mochitest",
|
|
267
|
+
"kwargs": {
|
|
268
|
+
"flavor": "browser-chrome",
|
|
269
|
+
"subsuite": "translations",
|
|
270
|
+
"test_paths": None,
|
|
271
|
+
},
|
|
272
|
+
"task_regex": [
|
|
273
|
+
"mochitest-browser-translations($|.*(-1|[^0-9])$)",
|
|
274
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
"mochitest-browser-chrome-ml-models": {
|
|
278
|
+
"aliases": ("bc-ml", "browser-ml-models"),
|
|
279
|
+
"build_flavor": "browser-chrome",
|
|
280
|
+
"mach_command": "mochitest",
|
|
281
|
+
"kwargs": {
|
|
282
|
+
"flavor": "browser-chrome",
|
|
283
|
+
"subsuite": "ml-models",
|
|
284
|
+
"test_paths": None,
|
|
285
|
+
},
|
|
286
|
+
"task_regex": [
|
|
287
|
+
"mochitest-browser-chrome-ml-models($|.*(-1|[^0-9])$)",
|
|
288
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
"mochitest-plain": {
|
|
292
|
+
"aliases": (
|
|
293
|
+
"mp",
|
|
294
|
+
"plain",
|
|
295
|
+
),
|
|
296
|
+
"build_flavor": "mochitest",
|
|
297
|
+
"mach_command": "mochitest",
|
|
298
|
+
"kwargs": {"flavor": "plain", "test_paths": None},
|
|
299
|
+
"task_regex": [
|
|
300
|
+
"mochitest-plain($|.*(-1|[^0-9])$)", # noqa
|
|
301
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
"mochitest-plain-gpu": {
|
|
305
|
+
"aliases": ("gpu",),
|
|
306
|
+
"build_flavor": "mochitest",
|
|
307
|
+
"mach_command": "mochitest",
|
|
308
|
+
"kwargs": {"flavor": "plain", "subsuite": "gpu", "test_paths": None},
|
|
309
|
+
"task_regex": [
|
|
310
|
+
"mochitest-gpu($|.*(-1|[^0-9])$)",
|
|
311
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
"mochitest-remote": {
|
|
315
|
+
"aliases": ("remote",),
|
|
316
|
+
"build_flavor": "browser-chrome",
|
|
317
|
+
"mach_command": "mochitest",
|
|
318
|
+
"kwargs": {
|
|
319
|
+
"flavor": "browser-chrome",
|
|
320
|
+
"subsuite": "remote",
|
|
321
|
+
"test_paths": None,
|
|
322
|
+
},
|
|
323
|
+
"task_regex": [
|
|
324
|
+
"mochitest-remote($|.*(-1|[^0-9])$)",
|
|
325
|
+
"test-verify($|.*(-1|[^0-9])$)",
|
|
326
|
+
],
|
|
327
|
+
},
|
|
328
|
+
"mochitest-webgl1-core": WebglSuite("webgl1-core"),
|
|
329
|
+
"mochitest-webgl1-ext": WebglSuite("webgl1-ext"),
|
|
330
|
+
"mochitest-webgl2-core": WebglSuite("webgl2-core"),
|
|
331
|
+
"mochitest-webgl2-ext": WebglSuite("webgl2-ext"),
|
|
332
|
+
"mochitest-webgl2-deqp": WebglSuite("webgl2-deqp"),
|
|
333
|
+
"mochitest-webgpu": WebglSuite("webgpu"),
|
|
334
|
+
"puppeteer": {
|
|
335
|
+
"aliases": ("remote/test/puppeteer",),
|
|
336
|
+
"mach_command": "puppeteer-test",
|
|
337
|
+
"kwargs": {"headless": False},
|
|
338
|
+
},
|
|
339
|
+
"python": {
|
|
340
|
+
"build_flavor": "python",
|
|
341
|
+
"mach_command": "python-test",
|
|
342
|
+
"kwargs": {"tests": None},
|
|
343
|
+
},
|
|
344
|
+
"telemetry-tests-client": {
|
|
345
|
+
"aliases": ("ttc",),
|
|
346
|
+
"build_flavor": "telemetry-tests-client",
|
|
347
|
+
"mach_command": "telemetry-tests-client",
|
|
348
|
+
"kwargs": {},
|
|
349
|
+
"task_regex": ["telemetry-tests-client($|.*(-1|[^0-9])$)"],
|
|
350
|
+
},
|
|
351
|
+
"reftest": {
|
|
352
|
+
"aliases": ("rr",),
|
|
353
|
+
"build_flavor": "reftest",
|
|
354
|
+
"mach_command": "reftest",
|
|
355
|
+
"kwargs": {"tests": None},
|
|
356
|
+
"task_regex": [
|
|
357
|
+
"(opt|debug)(-geckoview)?-reftest($|.*(-1|[^0-9])$)",
|
|
358
|
+
"test-verify-gpu($|.*(-1|[^0-9])$)",
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
"reftest-qr": {
|
|
362
|
+
"aliases": ("rr",),
|
|
363
|
+
"build_flavor": "reftest",
|
|
364
|
+
"mach_command": "reftest",
|
|
365
|
+
"kwargs": {"tests": None},
|
|
366
|
+
"task_regex": [
|
|
367
|
+
"(opt|debug)(-geckoview)?-reftest-qr($|.*(-1|[^0-9])$)",
|
|
368
|
+
"test-verify-gpu($|.*(-1|[^0-9])$)",
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
"web-platform-tests": {
|
|
372
|
+
"aliases": ("wpt",),
|
|
373
|
+
"mach_command": "web-platform-tests",
|
|
374
|
+
"build_flavor": "web-platform-tests",
|
|
375
|
+
"kwargs": {"subsuite": "testharness"},
|
|
376
|
+
"task_regex": [
|
|
377
|
+
"web-platform-tests(?!-crashtest|-reftest|-wdspec|-print|-aam)"
|
|
378
|
+
"($|.*(-1|[^0-9])$)",
|
|
379
|
+
"test-verify-wpt",
|
|
380
|
+
],
|
|
381
|
+
},
|
|
382
|
+
"web-platform-tests-crashtest": {
|
|
383
|
+
"aliases": ("wpt",),
|
|
384
|
+
"mach_command": "web-platform-tests",
|
|
385
|
+
"build_flavor": "web-platform-tests",
|
|
386
|
+
"kwargs": {"subsuite": "crashtest"},
|
|
387
|
+
"task_regex": [
|
|
388
|
+
"web-platform-tests-crashtest($|.*(-1|[^0-9])$)",
|
|
389
|
+
"test-verify-wpt",
|
|
390
|
+
],
|
|
391
|
+
},
|
|
392
|
+
"web-platform-tests-print-reftest": {
|
|
393
|
+
"aliases": ("wpt",),
|
|
394
|
+
"mach_command": "web-platform-tests",
|
|
395
|
+
"kwargs": {"subsuite": "print-reftest"},
|
|
396
|
+
"task_regex": [
|
|
397
|
+
"web-platform-tests-print-reftest($|.*(-1|[^0-9])$)",
|
|
398
|
+
"test-verify-wpt",
|
|
399
|
+
],
|
|
400
|
+
},
|
|
401
|
+
"web-platform-tests-reftest": {
|
|
402
|
+
"aliases": ("wpt",),
|
|
403
|
+
"mach_command": "web-platform-tests",
|
|
404
|
+
"build_flavor": "web-platform-tests",
|
|
405
|
+
"kwargs": {"subsuite": "reftest"},
|
|
406
|
+
"task_regex": [
|
|
407
|
+
"web-platform-tests-reftest($|.*(-1|[^0-9])$)",
|
|
408
|
+
"test-verify-wpt",
|
|
409
|
+
],
|
|
410
|
+
},
|
|
411
|
+
"web-platform-tests-wdspec": {
|
|
412
|
+
"aliases": ("wpt",),
|
|
413
|
+
"mach_command": "web-platform-tests",
|
|
414
|
+
"build_flavor": "web-platform-tests",
|
|
415
|
+
"kwargs": {"subsuite": "wdspec"},
|
|
416
|
+
"task_regex": [
|
|
417
|
+
"web-platform-tests-wdspec($|.*(-1|[^0-9])$)",
|
|
418
|
+
"test-verify-wpt",
|
|
419
|
+
],
|
|
420
|
+
},
|
|
421
|
+
"web-platform-tests-aam": {
|
|
422
|
+
"aliases": ("wpt",),
|
|
423
|
+
"mach_command": "web-platform-tests",
|
|
424
|
+
"build_flavor": "web-platform-tests",
|
|
425
|
+
"kwargs": {"subsuite": "aamtest"},
|
|
426
|
+
"task_regex": [
|
|
427
|
+
"web-platform-tests-aam($|.*(-1|[^0-9])$)",
|
|
428
|
+
"test-verify-wpt",
|
|
429
|
+
],
|
|
430
|
+
},
|
|
431
|
+
"valgrind": {
|
|
432
|
+
"aliases": ("v",),
|
|
433
|
+
"mach_command": "valgrind-test",
|
|
434
|
+
"kwargs": {},
|
|
435
|
+
},
|
|
436
|
+
"xpcshell": {
|
|
437
|
+
"aliases": ("x",),
|
|
438
|
+
"build_flavor": "xpcshell",
|
|
439
|
+
"mach_command": "xpcshell-test",
|
|
440
|
+
"kwargs": {"test_file": "all"},
|
|
441
|
+
"task_regex": ["xpcshell($|.*(-1|[^0-9])$)", "test-verify($|.*(-1|[^0-9])$)"],
|
|
442
|
+
},
|
|
443
|
+
"xpcshell-msix": {
|
|
444
|
+
"aliases": ("x",),
|
|
445
|
+
"build_flavor": "xpcshell",
|
|
446
|
+
"mach_command": "xpcshell-test",
|
|
447
|
+
"kwargs": {"test_file": "all"},
|
|
448
|
+
"task_regex": ["xpcshell($|.*(-1|[^0-9])$)", "test-verify($|.*(-1|[^0-9])$)"],
|
|
449
|
+
},
|
|
450
|
+
"fenix": {
|
|
451
|
+
"aliases": ("f",),
|
|
452
|
+
"build_flavor": "fenix",
|
|
453
|
+
"mach_command": "android-test",
|
|
454
|
+
"kwargs": {"subproject": "fenix"},
|
|
455
|
+
"root_path": "mobile/android/fenix",
|
|
456
|
+
"task_regex": ["(ui-)?test-apk-fenix($|.*(-1|[^0-9])$)"],
|
|
457
|
+
},
|
|
458
|
+
"focus": {
|
|
459
|
+
"aliases": ("f",),
|
|
460
|
+
"build_flavor": "focus",
|
|
461
|
+
"mach_command": "android-test",
|
|
462
|
+
"kwargs": {"subproject": "focus"},
|
|
463
|
+
"root_path": "mobile/android/focus-android",
|
|
464
|
+
"task_regex": ["(ui-)?test-apk-focus($|.*(-1|[^0-9])$)"],
|
|
465
|
+
},
|
|
466
|
+
"android-components": {
|
|
467
|
+
"aliases": ("ac",),
|
|
468
|
+
"build_flavor": "android-components",
|
|
469
|
+
"mach_command": "android-test",
|
|
470
|
+
"kwargs": {"subproject": "android-components"},
|
|
471
|
+
"root_path": "mobile/android/android-components",
|
|
472
|
+
"task_regex": ["(build|test)-components($|.*(-1|[^0-9])$)"],
|
|
473
|
+
},
|
|
474
|
+
"geckoview": {
|
|
475
|
+
"aliases": ("gv",),
|
|
476
|
+
"build_flavor": "geckoview",
|
|
477
|
+
"mach_command": "geckoview-junit",
|
|
478
|
+
"kwargs": {"no_install": False, "mach_test": True},
|
|
479
|
+
"root_path": "mobile/android/geckoview",
|
|
480
|
+
"task_regex": ["geckoview-junit($|.*(-1|[^0-9])$)"],
|
|
481
|
+
},
|
|
482
|
+
"junit": {
|
|
483
|
+
"aliases": ("j",),
|
|
484
|
+
"build_flavor": "geckoview",
|
|
485
|
+
"mach_command": "geckoview-junit",
|
|
486
|
+
"kwargs": {"no_install": False, "mach_test": True},
|
|
487
|
+
"task_regex": ["geckoview-junit($|.*(-1|[^0-9])$)"],
|
|
488
|
+
},
|
|
489
|
+
}
|
|
490
|
+
"""Definitions of all test suites and the metadata needed to run and process
|
|
491
|
+
them. Each test suite definition can contain the following keys.
|
|
492
|
+
|
|
493
|
+
Arguments:
|
|
494
|
+
aliases (tuple): A tuple containing shorthands used to refer to this suite.
|
|
495
|
+
build_flavor (str): The flavor assigned to this suite by the build system
|
|
496
|
+
in `mozbuild.testing.TEST_MANIFESTS` (or similar).
|
|
497
|
+
mach_command (str): Name of the mach command used to run this suite.
|
|
498
|
+
kwargs (dict): Arguments needed to pass into the mach command.
|
|
499
|
+
task_regex (list): A list of regexes used to filter task labels that run
|
|
500
|
+
this suite.
|
|
501
|
+
root_path (str): Source-relative directory path for this suite's project
|
|
502
|
+
root. When ``mach test`` receives this exact path, it
|
|
503
|
+
dispatches the suite directly instead of enumerating
|
|
504
|
+
individual test files.
|
|
505
|
+
"""
|
|
506
|
+
|
|
507
|
+
for i in range(1, MOCHITEST_TOTAL_CHUNKS + 1):
|
|
508
|
+
TEST_SUITES["mochitest-%d" % i] = {
|
|
509
|
+
"aliases": ("m%d" % i,),
|
|
510
|
+
"mach_command": "mochitest",
|
|
511
|
+
"kwargs": {
|
|
512
|
+
"flavor": "mochitest",
|
|
513
|
+
"subsuite": "default",
|
|
514
|
+
"chunk_by_dir": MOCHITEST_CHUNK_BY_DIR,
|
|
515
|
+
"total_chunks": MOCHITEST_TOTAL_CHUNKS,
|
|
516
|
+
"this_chunk": i,
|
|
517
|
+
"test_paths": None,
|
|
518
|
+
},
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
WPT_TYPES = set()
|
|
523
|
+
for suite, data in TEST_SUITES.items():
|
|
524
|
+
if suite.startswith("web-platform-tests"):
|
|
525
|
+
WPT_TYPES.add(data["kwargs"]["subsuite"])
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
_test_flavors = {
|
|
529
|
+
"a11y": "mochitest-a11y",
|
|
530
|
+
"browser-chrome": "mochitest-browser-chrome",
|
|
531
|
+
"chrome": "mochitest-chrome",
|
|
532
|
+
"crashtest": "crashtest",
|
|
533
|
+
"firefox-ui-functional": "firefox-ui-functional",
|
|
534
|
+
"firefox-ui-update": "firefox-ui-update",
|
|
535
|
+
"marionette": "marionette",
|
|
536
|
+
"mochitest": "mochitest-plain",
|
|
537
|
+
"puppeteer": "puppeteer",
|
|
538
|
+
"python": "python",
|
|
539
|
+
"reftest": "reftest",
|
|
540
|
+
"telemetry-tests-client": "telemetry-tests-client",
|
|
541
|
+
"web-platform-tests": "web-platform-tests",
|
|
542
|
+
"xpcshell": "xpcshell",
|
|
543
|
+
"fenix": "fenix",
|
|
544
|
+
"focus": "focus",
|
|
545
|
+
"android-components": "android-components",
|
|
546
|
+
"geckoview": "geckoview",
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
_test_subsuites = {
|
|
550
|
+
("browser-chrome", "a11y"): "mochitest-browser-a11y",
|
|
551
|
+
("browser-chrome", "devtools"): "mochitest-devtools-chrome",
|
|
552
|
+
("browser-chrome", "devtools-compat"): "mochitest-devtools-compat",
|
|
553
|
+
("browser-chrome", "media-bc"): "mochitest-browser-media",
|
|
554
|
+
("browser-chrome", "ml-models"): "mochitest-browser-chrome-ml-models",
|
|
555
|
+
("browser-chrome", "remote"): "mochitest-remote",
|
|
556
|
+
("browser-chrome", "screenshots"): "mochitest-browser-screenshots",
|
|
557
|
+
("browser-chrome", "translations"): "mochitest-browser-translations",
|
|
558
|
+
("chrome", "gpu"): "mochitest-chrome-gpu",
|
|
559
|
+
("marionette", "integration"): "marionette-integration",
|
|
560
|
+
("marionette", "unittest"): "marionette-unittest",
|
|
561
|
+
("mochitest", "gpu"): "mochitest-plain-gpu",
|
|
562
|
+
("mochitest", "media"): "mochitest-media",
|
|
563
|
+
("mochitest", "speech-recognition"): "mochitest-speech-recognition",
|
|
564
|
+
("mochitest", "webgl1-core"): "mochitest-webgl1-core",
|
|
565
|
+
("mochitest", "webgl1-ext"): "mochitest-webgl1-ext",
|
|
566
|
+
("mochitest", "webgl2-core"): "mochitest-webgl2-core",
|
|
567
|
+
("mochitest", "webgl2-ext"): "mochitest-webgl2-ext",
|
|
568
|
+
("mochitest", "webgl2-deqp"): "mochitest-webgl2-deqp",
|
|
569
|
+
("mochitest", "webgpu"): "mochitest-webgpu",
|
|
570
|
+
("web-platform-tests", "testharness"): "web-platform-tests",
|
|
571
|
+
("web-platform-tests", "crashtest"): "web-platform-tests-crashtest",
|
|
572
|
+
("web-platform-tests", "print-reftest"): "web-platform-tests-print-reftest",
|
|
573
|
+
("web-platform-tests", "reftest"): "web-platform-tests-reftest",
|
|
574
|
+
("web-platform-tests", "wdspec"): "web-platform-tests-wdspec",
|
|
575
|
+
("web-platform-tests", "aamtest"): "web-platform-tests-aam",
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def get_suite_definition(flavor, subsuite=None, strict=False):
|
|
580
|
+
"""Return a suite definition given a flavor and optional subsuite.
|
|
581
|
+
|
|
582
|
+
If strict is True, a subsuite must have its own entry in TEST_SUITES.
|
|
583
|
+
Otherwise, the entry for 'flavor' will be returned with the 'subsuite'
|
|
584
|
+
keyword arg set.
|
|
585
|
+
|
|
586
|
+
With or without strict mode, an empty dict will be returned if no
|
|
587
|
+
matching suite definition was found.
|
|
588
|
+
"""
|
|
589
|
+
if not subsuite:
|
|
590
|
+
suite_name = _test_flavors.get(flavor)
|
|
591
|
+
return suite_name, TEST_SUITES.get(suite_name, {}).copy()
|
|
592
|
+
|
|
593
|
+
suite_name = _test_subsuites.get((flavor, subsuite))
|
|
594
|
+
if suite_name or strict:
|
|
595
|
+
return suite_name, TEST_SUITES.get(suite_name, {}).copy()
|
|
596
|
+
|
|
597
|
+
suite_name = _test_flavors.get(flavor)
|
|
598
|
+
if suite_name not in TEST_SUITES:
|
|
599
|
+
return suite_name, {}
|
|
600
|
+
|
|
601
|
+
suite = TEST_SUITES[suite_name].copy()
|
|
602
|
+
suite.setdefault("kwargs", {})
|
|
603
|
+
suite["kwargs"]["subsuite"] = subsuite
|
|
604
|
+
return suite_name, suite
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def rewrite_test_base(test, new_base):
|
|
608
|
+
"""Rewrite paths in a test to be under a new base path.
|
|
609
|
+
|
|
610
|
+
This is useful for running tests from a separate location from where they
|
|
611
|
+
were defined.
|
|
612
|
+
"""
|
|
613
|
+
test["here"] = mozpath.join(new_base, test["dir_relpath"])
|
|
614
|
+
test["path"] = mozpath.join(new_base, test["file_relpath"])
|
|
615
|
+
return test
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
def _is_under(path, prefix):
|
|
619
|
+
return path == prefix or path.startswith(prefix.rstrip("/") + "/")
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
class TestLoader(MozbuildObject, metaclass=ABCMeta):
|
|
623
|
+
@abstractmethod
|
|
624
|
+
def __call__(self):
|
|
625
|
+
"""Generate test metadata."""
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
class BuildBackendLoader(TestLoader):
|
|
629
|
+
def __call__(self):
|
|
630
|
+
"""Loads the test metadata generated by the TestManifest build backend.
|
|
631
|
+
|
|
632
|
+
The data is stored in two files:
|
|
633
|
+
|
|
634
|
+
- <objdir>/all-tests.pkl
|
|
635
|
+
- <objdir>/test-defaults.pkl
|
|
636
|
+
|
|
637
|
+
The 'all-tests.pkl' file is a mapping of source path to test objects. The
|
|
638
|
+
'test-defaults.pkl' file maps manifests to their DEFAULT configuration.
|
|
639
|
+
These manifest defaults will be merged into the test configuration of the
|
|
640
|
+
contained tests.
|
|
641
|
+
"""
|
|
642
|
+
# If installing tests is going to result in re-generating the build
|
|
643
|
+
# backend, we need to do this here, so that the updated contents of
|
|
644
|
+
# all-tests.pkl make it to the set of tests to run.
|
|
645
|
+
if self.backend_out_of_date(
|
|
646
|
+
mozpath.join(self.topobjdir, "backend.TestManifestBackend")
|
|
647
|
+
):
|
|
648
|
+
print("Test configuration changed. Regenerating backend.")
|
|
649
|
+
from mozbuild.gen_test_backend import gen_test_backend
|
|
650
|
+
|
|
651
|
+
gen_test_backend()
|
|
652
|
+
# Only install when a prior full build has emitted the harness
|
|
653
|
+
# install manifest.
|
|
654
|
+
harness_manifest = mozpath.join(
|
|
655
|
+
self.topobjdir, "_build_manifests", "install", "_tests"
|
|
656
|
+
)
|
|
657
|
+
if os.path.isfile(harness_manifest):
|
|
658
|
+
install_test_files(
|
|
659
|
+
mozpath.normpath(self.topsrcdir),
|
|
660
|
+
self.topobjdir,
|
|
661
|
+
"_tests",
|
|
662
|
+
)
|
|
663
|
+
|
|
664
|
+
all_tests = os.path.join(self.topobjdir, "all-tests.pkl")
|
|
665
|
+
test_defaults = os.path.join(self.topobjdir, "test-defaults.pkl")
|
|
666
|
+
|
|
667
|
+
with open(all_tests, "rb") as fh:
|
|
668
|
+
test_data = pickle.load(fh)
|
|
669
|
+
|
|
670
|
+
with open(test_defaults, "rb") as fh:
|
|
671
|
+
defaults = pickle.load(fh)
|
|
672
|
+
|
|
673
|
+
# The keys in defaults use platform-specific path separators.
|
|
674
|
+
# self.topsrcdir was normalized to use /, revert back to \ if needed.
|
|
675
|
+
topsrcdir = os.path.normpath(self.topsrcdir)
|
|
676
|
+
|
|
677
|
+
for path, tests in test_data.items():
|
|
678
|
+
for metadata in tests:
|
|
679
|
+
defaults_manifests = [metadata["manifest"]]
|
|
680
|
+
|
|
681
|
+
# For test coverage on the generation and the reading of
|
|
682
|
+
# manifest_defaults with ancestor_manifest, see
|
|
683
|
+
# to_ancestor_manifest_path in the following test files:
|
|
684
|
+
# testing/mozbase/moztest/tests/test_resolve.py
|
|
685
|
+
# python/mozbuild/mozbuild/test/backend/test_test_manifest.py
|
|
686
|
+
ancestor_manifest = metadata.get("ancestor_manifest")
|
|
687
|
+
if ancestor_manifest:
|
|
688
|
+
# The (ancestor manifest, included manifest) tuple
|
|
689
|
+
# contains the defaults of the included manifest, so
|
|
690
|
+
# use it instead of [metadata['manifest']].
|
|
691
|
+
|
|
692
|
+
# ancestor_manifest is a relative path with
|
|
693
|
+
# platform-specific path separators.
|
|
694
|
+
defaults_manifests[0] = (ancestor_manifest, metadata["manifest"])
|
|
695
|
+
|
|
696
|
+
# defaults_manifests contains absolute paths with
|
|
697
|
+
# platform-specific path separators.
|
|
698
|
+
defaults_manifests.append(
|
|
699
|
+
os.path.join(topsrcdir, ancestor_manifest)
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
for manifest in defaults_manifests:
|
|
703
|
+
manifest_defaults = defaults.get(manifest)
|
|
704
|
+
if manifest_defaults:
|
|
705
|
+
metadata = combine_fields(manifest_defaults, metadata)
|
|
706
|
+
|
|
707
|
+
yield metadata
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
class TestManifestLoader(TestLoader):
|
|
711
|
+
def __init__(self, *args, **kwargs):
|
|
712
|
+
super().__init__(*args, **kwargs)
|
|
713
|
+
self.finder = FileFinder(self.topsrcdir)
|
|
714
|
+
# Checkouts in automation are clean, checking it again on sparse
|
|
715
|
+
# checkouts (e.g. in decision tasks) is slow.
|
|
716
|
+
self.reader = self.mozbuild_reader(
|
|
717
|
+
config_mode="empty", vcs_check_clean="MOZ_AUTOMATION" not in os.environ
|
|
718
|
+
)
|
|
719
|
+
self.variables = {f"{k}_MANIFESTS": v[0] for k, v in TEST_MANIFESTS.items()}
|
|
720
|
+
self.variables.update({f"{f.upper()}_MANIFESTS": f for f in REFTEST_FLAVORS})
|
|
721
|
+
|
|
722
|
+
def _load_manifestparser_manifest(self, mpath):
|
|
723
|
+
mp = TestManifest(
|
|
724
|
+
manifests=[mpath],
|
|
725
|
+
strict=True,
|
|
726
|
+
rootdir=self.topsrcdir,
|
|
727
|
+
finder=self.finder,
|
|
728
|
+
handle_defaults=True,
|
|
729
|
+
)
|
|
730
|
+
return (test for test in mp.tests)
|
|
731
|
+
|
|
732
|
+
def _load_reftest_manifest(self, mpath):
|
|
733
|
+
import reftest
|
|
734
|
+
|
|
735
|
+
manifest = reftest.ReftestManifest(finder=self.finder)
|
|
736
|
+
manifest.load(mpath)
|
|
737
|
+
|
|
738
|
+
for test in sorted(manifest.tests, key=lambda x: x.get("path")):
|
|
739
|
+
test["manifest_relpath"] = test["manifest"][len(self.topsrcdir) + 1 :]
|
|
740
|
+
yield test
|
|
741
|
+
|
|
742
|
+
# Sub-manifests with no file-based tests (e.g. those containing only
|
|
743
|
+
# data: URL tests, which ReftestManifest skips) would otherwise be
|
|
744
|
+
# invisible to the taskgraph manifest loader. Yield a placeholder so
|
|
745
|
+
# they still get scheduled.
|
|
746
|
+
manifests_with_tests = {t["manifest"] for t in manifest.tests}
|
|
747
|
+
for manifest_path, info in sorted(manifest.manifests.items()):
|
|
748
|
+
# Skip the top-level manifest: it is the task entry point and
|
|
749
|
+
# needs no placeholder.
|
|
750
|
+
if manifest_path == manifest.path:
|
|
751
|
+
continue
|
|
752
|
+
# has_test_lines excludes include-only manifests: manifest.sys.mjs
|
|
753
|
+
# skips include recursion when MOZHARNESS_TEST_PATHS is set, so
|
|
754
|
+
# they would run 0 tests if directly targeted. Their sub-manifests
|
|
755
|
+
# are already scheduled independently.
|
|
756
|
+
if manifest_path not in manifests_with_tests and info["has_test_lines"]:
|
|
757
|
+
relpath = manifest_path[len(self.topsrcdir) + 1 :]
|
|
758
|
+
placeholder = {
|
|
759
|
+
"path": manifest_path,
|
|
760
|
+
"here": os.path.dirname(manifest_path),
|
|
761
|
+
"manifest": manifest_path,
|
|
762
|
+
"manifest_relpath": relpath,
|
|
763
|
+
"name": os.path.basename(manifest_path),
|
|
764
|
+
"head": "",
|
|
765
|
+
"support-files": "",
|
|
766
|
+
"subsuite": "",
|
|
767
|
+
}
|
|
768
|
+
skip_if = (
|
|
769
|
+
info["tests_skip_if"]
|
|
770
|
+
if info["tests_skip_if"] is not None
|
|
771
|
+
else info["include_skip_if"]
|
|
772
|
+
)
|
|
773
|
+
if skip_if:
|
|
774
|
+
placeholder["skip-if"] = skip_if
|
|
775
|
+
yield placeholder
|
|
776
|
+
|
|
777
|
+
def __call__(self):
|
|
778
|
+
for path, name, key, value in self.reader.find_variables_from_ast(
|
|
779
|
+
self.variables
|
|
780
|
+
):
|
|
781
|
+
mpath = os.path.join(self.topsrcdir, os.path.dirname(path), value)
|
|
782
|
+
flavor = self.variables[name]
|
|
783
|
+
|
|
784
|
+
if name.rsplit("_", 1)[0].lower() in REFTEST_FLAVORS:
|
|
785
|
+
tests = self._load_reftest_manifest(mpath)
|
|
786
|
+
else:
|
|
787
|
+
tests = self._load_manifestparser_manifest(mpath)
|
|
788
|
+
|
|
789
|
+
for test in tests:
|
|
790
|
+
path = mozpath.normpath(test["path"])
|
|
791
|
+
assert mozpath.basedir(path, [self.topsrcdir])
|
|
792
|
+
relpath = path[len(self.topsrcdir) + 1 :]
|
|
793
|
+
|
|
794
|
+
# Add these keys for compatibility with the build backend loader.
|
|
795
|
+
test["flavor"] = flavor
|
|
796
|
+
test["file_relpath"] = relpath
|
|
797
|
+
test["srcdir_relpath"] = relpath
|
|
798
|
+
test["dir_relpath"] = mozpath.dirname(relpath)
|
|
799
|
+
|
|
800
|
+
yield test
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
class TestResolver(MozbuildObject):
|
|
804
|
+
"""Helper to resolve tests from the current environment to test files."""
|
|
805
|
+
|
|
806
|
+
test_rewrites = {
|
|
807
|
+
"a11y": "_tests/testing/mochitest/a11y",
|
|
808
|
+
"browser-chrome": "_tests/testing/mochitest/browser",
|
|
809
|
+
"chrome": "_tests/testing/mochitest/chrome",
|
|
810
|
+
"mochitest": "_tests/testing/mochitest/tests",
|
|
811
|
+
"xpcshell": "_tests/xpcshell",
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
def __init__(self, *args, **kwargs):
|
|
815
|
+
loader_cls = kwargs.pop("loader_cls", BuildBackendLoader)
|
|
816
|
+
super().__init__(*args, **kwargs)
|
|
817
|
+
|
|
818
|
+
self.load_tests = self._spawn(loader_cls)
|
|
819
|
+
self._tests = []
|
|
820
|
+
self._reset_state()
|
|
821
|
+
|
|
822
|
+
# These suites aren't registered in moz.build so require special handling.
|
|
823
|
+
self._puppeteer_loaded = False
|
|
824
|
+
self._fenix_loaded = False
|
|
825
|
+
self._ac_loaded = False
|
|
826
|
+
self._focus_loaded = False
|
|
827
|
+
self._geckoview_junit_loaded = False
|
|
828
|
+
self._tests_loaded = False
|
|
829
|
+
self._wpt_loaded = False
|
|
830
|
+
|
|
831
|
+
def _reset_state(self):
|
|
832
|
+
self._tests_by_path = defaultdict(list)
|
|
833
|
+
self._tests_by_flavor = defaultdict(set)
|
|
834
|
+
self._tests_by_manifest = defaultdict(list)
|
|
835
|
+
self._test_dirs = set()
|
|
836
|
+
|
|
837
|
+
@property
|
|
838
|
+
def tests(self):
|
|
839
|
+
if not self._tests_loaded:
|
|
840
|
+
self._reset_state()
|
|
841
|
+
for test in self.load_tests():
|
|
842
|
+
self._tests.append(test)
|
|
843
|
+
self._tests_loaded = True
|
|
844
|
+
return self._tests
|
|
845
|
+
|
|
846
|
+
@property
|
|
847
|
+
def tests_by_path(self):
|
|
848
|
+
if not self._tests_by_path:
|
|
849
|
+
for test in self.tests:
|
|
850
|
+
self._tests_by_path[test["file_relpath"]].append(test)
|
|
851
|
+
return self._tests_by_path
|
|
852
|
+
|
|
853
|
+
@property
|
|
854
|
+
def tests_by_flavor(self):
|
|
855
|
+
if not self._tests_by_flavor:
|
|
856
|
+
for test in self.tests:
|
|
857
|
+
self._tests_by_flavor[test["flavor"]].add(test["file_relpath"])
|
|
858
|
+
return self._tests_by_flavor
|
|
859
|
+
|
|
860
|
+
@property
|
|
861
|
+
def tests_by_manifest(self):
|
|
862
|
+
if not self._tests_by_manifest:
|
|
863
|
+
for test in self.tests:
|
|
864
|
+
if test["flavor"] == "web-platform-tests":
|
|
865
|
+
# Use test ids instead of paths for WPT.
|
|
866
|
+
self._tests_by_manifest[test["manifest"]].append(test["name"])
|
|
867
|
+
else:
|
|
868
|
+
relpath = mozpath.relpath(
|
|
869
|
+
test["path"], mozpath.dirname(test["manifest"])
|
|
870
|
+
)
|
|
871
|
+
self._tests_by_manifest[test["manifest_relpath"]].append(relpath)
|
|
872
|
+
return self._tests_by_manifest
|
|
873
|
+
|
|
874
|
+
@cache
|
|
875
|
+
def get_test_paths_by_manifest(self, suite, paths):
|
|
876
|
+
"""Find the manifests of ``suite`` that contain tests under ``paths``.
|
|
877
|
+
|
|
878
|
+
Args:
|
|
879
|
+
suite (str): The suite to look at. Values are keys of `TEST_SUITES`.
|
|
880
|
+
paths (frozenset): Source directories or test files, relative to the
|
|
881
|
+
source root.
|
|
882
|
+
|
|
883
|
+
Returns:
|
|
884
|
+
A dict mapping each manifest holding at least one test under ``paths``
|
|
885
|
+
to the paths that should be run from it. A manifest maps to itself when
|
|
886
|
+
it lives under one of ``paths``, and to the requested paths when they
|
|
887
|
+
are narrower than the manifest (a single test file, or a subdirectory
|
|
888
|
+
of the manifest's directory).
|
|
889
|
+
"""
|
|
890
|
+
suite_definition = TEST_SUITES[suite]
|
|
891
|
+
kwargs = {
|
|
892
|
+
"flavor": suite_definition["build_flavor"],
|
|
893
|
+
"subsuite": suite_definition.get("kwargs", {}).get("subsuite", "undefined"),
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
by_manifest = {}
|
|
897
|
+
for path in paths:
|
|
898
|
+
for test in self.resolve_tests(paths=[path], **kwargs):
|
|
899
|
+
manifest = chunk_by_runtime.get_manifest(test)
|
|
900
|
+
# Run the manifest itself when it is entirely under the requested
|
|
901
|
+
# path, and the requested path when it is the narrower of the two.
|
|
902
|
+
test_path = manifest if _is_under(manifest, path) else path
|
|
903
|
+
by_manifest.setdefault(manifest, set()).add(test_path)
|
|
904
|
+
|
|
905
|
+
return {
|
|
906
|
+
manifest: [manifest] if manifest in test_paths else sorted(test_paths)
|
|
907
|
+
for manifest, test_paths in by_manifest.items()
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
@property
|
|
911
|
+
def test_dirs(self):
|
|
912
|
+
if not self._test_dirs:
|
|
913
|
+
for test in self.tests:
|
|
914
|
+
self._test_dirs.add(test["dir_relpath"])
|
|
915
|
+
return self._test_dirs
|
|
916
|
+
|
|
917
|
+
@cache
|
|
918
|
+
def _get_metadata_paths(self, metadata_base, dir_path):
|
|
919
|
+
|
|
920
|
+
paths = []
|
|
921
|
+
path_parts = dir_path.split(os.path.sep) if dir_path else []
|
|
922
|
+
|
|
923
|
+
for i in range(1, len(path_parts) + 1):
|
|
924
|
+
dir_ini = os.path.join(
|
|
925
|
+
metadata_base, os.path.sep.join(path_parts[:i]), "__dir__.ini"
|
|
926
|
+
)
|
|
927
|
+
if os.path.exists(dir_ini):
|
|
928
|
+
paths.append(dir_ini)
|
|
929
|
+
|
|
930
|
+
return tuple(paths)
|
|
931
|
+
|
|
932
|
+
@cache
|
|
933
|
+
def _extract_tags_from_file(self, file_path):
|
|
934
|
+
"""Return the root-level ``tags`` of a wptrunner metadata file.
|
|
935
|
+
|
|
936
|
+
Only the few files with an unindented ``tags`` key are handed to
|
|
937
|
+
wptmanifest, as parsing all of them is too slow for the decision task.
|
|
938
|
+
"""
|
|
939
|
+
try:
|
|
940
|
+
with open(file_path, "rb") as f:
|
|
941
|
+
content = f.read()
|
|
942
|
+
except OSError:
|
|
943
|
+
return ()
|
|
944
|
+
|
|
945
|
+
if not ROOT_TAGS_RE.search(content):
|
|
946
|
+
return ()
|
|
947
|
+
|
|
948
|
+
from wptrunner.wptmanifest.node import KeyValueNode, ListNode, ValueNode
|
|
949
|
+
from wptrunner.wptmanifest.parser import parse
|
|
950
|
+
|
|
951
|
+
try:
|
|
952
|
+
root = parse(content)
|
|
953
|
+
except Exception:
|
|
954
|
+
return ()
|
|
955
|
+
for node in root.children:
|
|
956
|
+
if not isinstance(node, KeyValueNode) or node.data != "tags":
|
|
957
|
+
continue
|
|
958
|
+
for value in node.children:
|
|
959
|
+
if isinstance(value, ListNode):
|
|
960
|
+
return tuple(str(child.data) for child in value.children)
|
|
961
|
+
if isinstance(value, ValueNode):
|
|
962
|
+
return (str(value.data),)
|
|
963
|
+
return ()
|
|
964
|
+
|
|
965
|
+
def get_test_tags(self, test_tags, metadata_base, path):
|
|
966
|
+
|
|
967
|
+
dir_path = os.path.dirname(path) if path else ""
|
|
968
|
+
dir_metadata_paths = self._get_metadata_paths(metadata_base, dir_path)
|
|
969
|
+
|
|
970
|
+
test_metadata = os.path.join(metadata_base, f"{path}.ini")
|
|
971
|
+
if os.path.exists(test_metadata):
|
|
972
|
+
all_paths = list(dir_metadata_paths) + [test_metadata]
|
|
973
|
+
else:
|
|
974
|
+
all_paths = dir_metadata_paths
|
|
975
|
+
|
|
976
|
+
for file_path in all_paths:
|
|
977
|
+
test_tags.extend(self._extract_tags_from_file(file_path))
|
|
978
|
+
|
|
979
|
+
return list(set(test_tags))
|
|
980
|
+
|
|
981
|
+
def _resolve(
|
|
982
|
+
self, paths=None, flavor="", subsuite=None, under_path=None, tags=None
|
|
983
|
+
):
|
|
984
|
+
"""Given parameters, resolve them to produce an appropriate list of tests.
|
|
985
|
+
|
|
986
|
+
Args:
|
|
987
|
+
paths (list):
|
|
988
|
+
By default, set to None. If provided as a list of paths, then
|
|
989
|
+
this method will attempt to load the appropriate set of tests
|
|
990
|
+
that live in this path.
|
|
991
|
+
|
|
992
|
+
flavor (string):
|
|
993
|
+
By default, an empty string. If provided as a string, then this
|
|
994
|
+
method will attempt to load tests that belong to this flavor.
|
|
995
|
+
Additional filtering also takes the flavor into consideration.
|
|
996
|
+
|
|
997
|
+
subsuite (string):
|
|
998
|
+
By default, set to None. If provided as a string, then this value
|
|
999
|
+
is used to perform filtering of a candidate set of tests.
|
|
1000
|
+
"""
|
|
1001
|
+
if tags:
|
|
1002
|
+
tags = set(tags)
|
|
1003
|
+
|
|
1004
|
+
def fltr(tests):
|
|
1005
|
+
"""Filters tests based on several criteria.
|
|
1006
|
+
|
|
1007
|
+
Args:
|
|
1008
|
+
tests (list):
|
|
1009
|
+
List of tests that belong to the same candidate path.
|
|
1010
|
+
|
|
1011
|
+
Returns:
|
|
1012
|
+
test (dict):
|
|
1013
|
+
If the test survived the filtering process, it is returned
|
|
1014
|
+
as a valid test.
|
|
1015
|
+
"""
|
|
1016
|
+
for test in tests:
|
|
1017
|
+
if flavor:
|
|
1018
|
+
if flavor == "devtools" and test.get("flavor") != "browser-chrome":
|
|
1019
|
+
continue
|
|
1020
|
+
if flavor != "devtools" and test.get("flavor") != flavor:
|
|
1021
|
+
continue
|
|
1022
|
+
|
|
1023
|
+
# Marionette subsuite 'unittest' runs unit-tests.toml
|
|
1024
|
+
if flavor == "marionette" and test.get("subtest", "") != "unittest":
|
|
1025
|
+
if "unit-tests.toml" in test.get("manifest", ""):
|
|
1026
|
+
continue
|
|
1027
|
+
|
|
1028
|
+
test_subsuite = test.get("subsuite", "undefined")
|
|
1029
|
+
if not test_subsuite: # sometimes test['subsuite'] == ''
|
|
1030
|
+
test_subsuite = "undefined"
|
|
1031
|
+
if subsuite and test_subsuite != subsuite:
|
|
1032
|
+
continue
|
|
1033
|
+
|
|
1034
|
+
test_tags = set(test.get("tags", "").split())
|
|
1035
|
+
if tags and not (tags & test_tags):
|
|
1036
|
+
continue
|
|
1037
|
+
|
|
1038
|
+
if under_path and not test["file_relpath"].startswith(under_path):
|
|
1039
|
+
continue
|
|
1040
|
+
|
|
1041
|
+
# Make a copy so modifications don't change the source.
|
|
1042
|
+
yield dict(test)
|
|
1043
|
+
|
|
1044
|
+
paths = paths or []
|
|
1045
|
+
paths = [mozpath.normpath(p) for p in paths]
|
|
1046
|
+
if not paths:
|
|
1047
|
+
paths = [None]
|
|
1048
|
+
|
|
1049
|
+
if flavor in ("", "puppeteer", None) and (
|
|
1050
|
+
any(self.is_puppeteer_path(p) for p in paths) or paths == [None]
|
|
1051
|
+
):
|
|
1052
|
+
self.add_puppeteer_manifest_data()
|
|
1053
|
+
|
|
1054
|
+
if flavor in ("", "web-platform-tests", None) and (
|
|
1055
|
+
any(self.is_wpt_path(p) for p in paths) or paths == [None]
|
|
1056
|
+
):
|
|
1057
|
+
self.add_wpt_manifest_data()
|
|
1058
|
+
|
|
1059
|
+
if flavor in ("", "fenix", None) and (
|
|
1060
|
+
any(self.is_fenix_path(p) for p in paths) or paths == [None]
|
|
1061
|
+
):
|
|
1062
|
+
self.add_fenix_manifest_data()
|
|
1063
|
+
|
|
1064
|
+
if flavor in ("", "focus", None) and (
|
|
1065
|
+
any(self.is_focus_path(p) for p in paths) or paths == [None]
|
|
1066
|
+
):
|
|
1067
|
+
self.add_focus_manifest_data()
|
|
1068
|
+
|
|
1069
|
+
if flavor in ("", "android-components", None) and (
|
|
1070
|
+
any(self.is_ac_path(p) for p in paths) or paths == [None]
|
|
1071
|
+
):
|
|
1072
|
+
self.add_ac_manifest_data()
|
|
1073
|
+
|
|
1074
|
+
if flavor in ("", "geckoview", "junit", None) and (
|
|
1075
|
+
any(self.is_geckoview_junit_path(p) for p in paths) or paths == [None]
|
|
1076
|
+
):
|
|
1077
|
+
self.add_geckoview_junit_manifest_data()
|
|
1078
|
+
|
|
1079
|
+
candidate_paths = set()
|
|
1080
|
+
|
|
1081
|
+
for path in sorted(paths):
|
|
1082
|
+
if path is None:
|
|
1083
|
+
candidate_paths |= set(self.tests_by_path.keys())
|
|
1084
|
+
continue
|
|
1085
|
+
|
|
1086
|
+
if "*" in path:
|
|
1087
|
+
candidate_paths |= {
|
|
1088
|
+
p for p in self.tests_by_path if mozpath.match(p, path)
|
|
1089
|
+
}
|
|
1090
|
+
continue
|
|
1091
|
+
|
|
1092
|
+
# If the path is a directory, or the path is a prefix of a directory
|
|
1093
|
+
# containing tests, pull in all tests in that directory.
|
|
1094
|
+
if path in self.test_dirs or any(
|
|
1095
|
+
p.startswith(path) for p in self.tests_by_path
|
|
1096
|
+
):
|
|
1097
|
+
candidate_paths |= {p for p in self.tests_by_path if p.startswith(path)}
|
|
1098
|
+
continue
|
|
1099
|
+
|
|
1100
|
+
# If the path is a manifest, add all tests defined in that manifest.
|
|
1101
|
+
if any(path.endswith(e) for e in (".toml", ".ini", ".list")):
|
|
1102
|
+
key = "manifest" if os.path.isabs(path) else "manifest_relpath"
|
|
1103
|
+
candidate_paths |= {
|
|
1104
|
+
t["file_relpath"]
|
|
1105
|
+
for t in self.tests
|
|
1106
|
+
if key in t and mozpath.normpath(t[key]) == path
|
|
1107
|
+
}
|
|
1108
|
+
continue
|
|
1109
|
+
|
|
1110
|
+
# If it's a test file, add just that file.
|
|
1111
|
+
candidate_paths |= {p for p in self.tests_by_path if path in p}
|
|
1112
|
+
|
|
1113
|
+
for p in sorted(candidate_paths):
|
|
1114
|
+
tests = self.tests_by_path[p]
|
|
1115
|
+
yield from fltr(tests)
|
|
1116
|
+
|
|
1117
|
+
def is_puppeteer_path(self, path):
|
|
1118
|
+
if path is None:
|
|
1119
|
+
return True
|
|
1120
|
+
return mozpath.match(path, "remote/test/puppeteer/test/**")
|
|
1121
|
+
|
|
1122
|
+
def is_fenix_path(self, path):
|
|
1123
|
+
if path is None:
|
|
1124
|
+
return True
|
|
1125
|
+
return mozpath.match(path, "mobile/android/fenix/**")
|
|
1126
|
+
|
|
1127
|
+
def is_focus_path(self, path):
|
|
1128
|
+
if path is None:
|
|
1129
|
+
return True
|
|
1130
|
+
return mozpath.match(path, "mobile/android/focus-android/**")
|
|
1131
|
+
|
|
1132
|
+
def is_ac_path(self, path):
|
|
1133
|
+
if path is None:
|
|
1134
|
+
return True
|
|
1135
|
+
return mozpath.match(path, "mobile/android/android-components/**")
|
|
1136
|
+
|
|
1137
|
+
def is_geckoview_junit_path(self, path):
|
|
1138
|
+
if path is None:
|
|
1139
|
+
return True
|
|
1140
|
+
return mozpath.match(path, "mobile/android/geckoview/**")
|
|
1141
|
+
|
|
1142
|
+
def add_puppeteer_manifest_data(self):
|
|
1143
|
+
if self._puppeteer_loaded:
|
|
1144
|
+
return
|
|
1145
|
+
|
|
1146
|
+
self._reset_state()
|
|
1147
|
+
|
|
1148
|
+
test_path = os.path.join(self.topsrcdir, "remote", "test", "puppeteer", "test")
|
|
1149
|
+
for root, dirs, paths in os.walk(test_path):
|
|
1150
|
+
for filename in fnmatch.filter(paths, "*.spec.js"):
|
|
1151
|
+
path = os.path.join(root, filename)
|
|
1152
|
+
relpath = mozpath.relpath(mozpath.normpath(path), self.topsrcdir)
|
|
1153
|
+
self._tests.append({
|
|
1154
|
+
"path": os.path.abspath(path),
|
|
1155
|
+
"flavor": "puppeteer",
|
|
1156
|
+
"here": os.path.dirname(path),
|
|
1157
|
+
"manifest": None,
|
|
1158
|
+
"name": relpath,
|
|
1159
|
+
"file_relpath": relpath,
|
|
1160
|
+
"head": "",
|
|
1161
|
+
"support-files": "",
|
|
1162
|
+
"subsuite": "puppeteer",
|
|
1163
|
+
"dir_relpath": mozpath.dirname(relpath),
|
|
1164
|
+
"srcdir_relpath": relpath,
|
|
1165
|
+
})
|
|
1166
|
+
|
|
1167
|
+
self._puppeteer_loaded = True
|
|
1168
|
+
|
|
1169
|
+
def add_fenix_manifest_data(self):
|
|
1170
|
+
if self._fenix_loaded:
|
|
1171
|
+
return
|
|
1172
|
+
|
|
1173
|
+
self._reset_state()
|
|
1174
|
+
|
|
1175
|
+
app_dir = os.path.join(self.topsrcdir, "mobile", "android", "fenix", "app")
|
|
1176
|
+
test_subdirs = (
|
|
1177
|
+
os.path.join("src", "test", "java"),
|
|
1178
|
+
os.path.join("src", "test", "kotlin"),
|
|
1179
|
+
)
|
|
1180
|
+
for root, dirs, paths in os.walk(app_dir):
|
|
1181
|
+
if any(sd in root for sd in test_subdirs):
|
|
1182
|
+
for filename in fnmatch.filter(paths, "*.kt"):
|
|
1183
|
+
path = os.path.join(root, filename)
|
|
1184
|
+
relpath = mozpath.relpath(mozpath.normpath(path), self.topsrcdir)
|
|
1185
|
+
self._tests.append({
|
|
1186
|
+
"path": os.path.abspath(path),
|
|
1187
|
+
"flavor": "fenix",
|
|
1188
|
+
"here": os.path.dirname(path),
|
|
1189
|
+
"manifest": None,
|
|
1190
|
+
"name": relpath,
|
|
1191
|
+
"file_relpath": relpath,
|
|
1192
|
+
"head": "",
|
|
1193
|
+
"support-files": "",
|
|
1194
|
+
"subsuite": "",
|
|
1195
|
+
"dir_relpath": mozpath.dirname(relpath),
|
|
1196
|
+
"srcdir_relpath": relpath,
|
|
1197
|
+
})
|
|
1198
|
+
dirs[:] = [d for d in dirs if d != "build"]
|
|
1199
|
+
|
|
1200
|
+
self._fenix_loaded = True
|
|
1201
|
+
|
|
1202
|
+
def add_focus_manifest_data(self):
|
|
1203
|
+
if self._focus_loaded:
|
|
1204
|
+
return
|
|
1205
|
+
|
|
1206
|
+
self._reset_state()
|
|
1207
|
+
|
|
1208
|
+
test_path = os.path.join(
|
|
1209
|
+
self.topsrcdir,
|
|
1210
|
+
"mobile",
|
|
1211
|
+
"android",
|
|
1212
|
+
"focus-android",
|
|
1213
|
+
"app",
|
|
1214
|
+
"src",
|
|
1215
|
+
"test",
|
|
1216
|
+
"java",
|
|
1217
|
+
)
|
|
1218
|
+
for root, dirs, paths in os.walk(test_path):
|
|
1219
|
+
if "test" in root:
|
|
1220
|
+
for filename in fnmatch.filter(paths, "*.kt"):
|
|
1221
|
+
path = os.path.join(root, filename)
|
|
1222
|
+
relpath = mozpath.relpath(mozpath.normpath(path), self.topsrcdir)
|
|
1223
|
+
self._tests.append({
|
|
1224
|
+
"path": os.path.abspath(path),
|
|
1225
|
+
"flavor": "focus",
|
|
1226
|
+
"here": os.path.dirname(path),
|
|
1227
|
+
"manifest": None,
|
|
1228
|
+
"name": relpath,
|
|
1229
|
+
"file_relpath": relpath,
|
|
1230
|
+
"head": "",
|
|
1231
|
+
"support-files": "",
|
|
1232
|
+
"subsuite": "",
|
|
1233
|
+
"dir_relpath": mozpath.dirname(relpath),
|
|
1234
|
+
"srcdir_relpath": relpath,
|
|
1235
|
+
})
|
|
1236
|
+
|
|
1237
|
+
self._focus_loaded = True
|
|
1238
|
+
|
|
1239
|
+
def add_ac_manifest_data(self):
|
|
1240
|
+
if self._ac_loaded:
|
|
1241
|
+
return
|
|
1242
|
+
|
|
1243
|
+
self._reset_state()
|
|
1244
|
+
|
|
1245
|
+
test_path = os.path.join(
|
|
1246
|
+
self.topsrcdir, "mobile", "android", "android-components"
|
|
1247
|
+
)
|
|
1248
|
+
|
|
1249
|
+
test_subdir_path = os.path.join("src", "test", "java")
|
|
1250
|
+
for root, dirs, paths in os.walk(test_path):
|
|
1251
|
+
if test_subdir_path in root:
|
|
1252
|
+
for filename in fnmatch.filter(paths, "*.kt"):
|
|
1253
|
+
path = os.path.join(root, filename)
|
|
1254
|
+
relpath = mozpath.relpath(mozpath.normpath(path), self.topsrcdir)
|
|
1255
|
+
self._tests.append({
|
|
1256
|
+
"path": os.path.abspath(path),
|
|
1257
|
+
"flavor": "android-components",
|
|
1258
|
+
"here": os.path.dirname(path),
|
|
1259
|
+
"manifest": None,
|
|
1260
|
+
"name": relpath,
|
|
1261
|
+
"file_relpath": relpath,
|
|
1262
|
+
"head": "",
|
|
1263
|
+
"support-files": "",
|
|
1264
|
+
"subsuite": "",
|
|
1265
|
+
"dir_relpath": mozpath.dirname(relpath),
|
|
1266
|
+
"srcdir_relpath": relpath,
|
|
1267
|
+
})
|
|
1268
|
+
|
|
1269
|
+
self._ac_loaded = True
|
|
1270
|
+
|
|
1271
|
+
def add_geckoview_junit_manifest_data(self):
|
|
1272
|
+
if self._geckoview_junit_loaded:
|
|
1273
|
+
return
|
|
1274
|
+
|
|
1275
|
+
self._reset_state()
|
|
1276
|
+
|
|
1277
|
+
test_path = os.path.join(
|
|
1278
|
+
self.topsrcdir,
|
|
1279
|
+
"mobile",
|
|
1280
|
+
"android",
|
|
1281
|
+
"geckoview",
|
|
1282
|
+
"src",
|
|
1283
|
+
"androidTest",
|
|
1284
|
+
"java",
|
|
1285
|
+
)
|
|
1286
|
+
for root, dirs, paths in os.walk(test_path):
|
|
1287
|
+
if "test" in root:
|
|
1288
|
+
for filename in fnmatch.filter(paths, "*.kt"):
|
|
1289
|
+
path = os.path.join(root, filename)
|
|
1290
|
+
relpath = mozpath.relpath(mozpath.normpath(path), self.topsrcdir)
|
|
1291
|
+
self._tests.append({
|
|
1292
|
+
"path": os.path.abspath(path),
|
|
1293
|
+
"flavor": "geckoview",
|
|
1294
|
+
"here": os.path.dirname(path),
|
|
1295
|
+
"manifest": None,
|
|
1296
|
+
"name": relpath,
|
|
1297
|
+
"file_relpath": relpath,
|
|
1298
|
+
"head": "",
|
|
1299
|
+
"support-files": "",
|
|
1300
|
+
"subsuite": "",
|
|
1301
|
+
"dir_relpath": mozpath.dirname(relpath),
|
|
1302
|
+
"srcdir_relpath": relpath,
|
|
1303
|
+
})
|
|
1304
|
+
|
|
1305
|
+
self._geckooview_junit_loaded = True
|
|
1306
|
+
|
|
1307
|
+
def is_wpt_path(self, path):
|
|
1308
|
+
"""Checks if path forms part of the known web-platform-test paths.
|
|
1309
|
+
|
|
1310
|
+
Args:
|
|
1311
|
+
path (str or None):
|
|
1312
|
+
Path to check against the list of known web-platform-test paths.
|
|
1313
|
+
|
|
1314
|
+
Returns:
|
|
1315
|
+
Boolean value. True if path is part of web-platform-tests path, or
|
|
1316
|
+
path is None. False otherwise.
|
|
1317
|
+
"""
|
|
1318
|
+
if path is None:
|
|
1319
|
+
return True
|
|
1320
|
+
if mozpath.match(path, "testing/web-platform/tests/**"):
|
|
1321
|
+
return True
|
|
1322
|
+
if mozpath.match(path, "testing/web-platform/mozilla/tests/**"):
|
|
1323
|
+
return True
|
|
1324
|
+
return False
|
|
1325
|
+
|
|
1326
|
+
def get_wpt_group(self, test, depth=3):
|
|
1327
|
+
"""Given a test object set the group (aka manifest) that it belongs to.
|
|
1328
|
+
|
|
1329
|
+
If a custom value for `depth` is provided, it will override the default
|
|
1330
|
+
value of 3 path components.
|
|
1331
|
+
|
|
1332
|
+
Args:
|
|
1333
|
+
test (dict): Test object for the particular suite and subsuite.
|
|
1334
|
+
depth (int, optional): Custom number of path elements.
|
|
1335
|
+
|
|
1336
|
+
Returns:
|
|
1337
|
+
str: The group the given test belongs to.
|
|
1338
|
+
"""
|
|
1339
|
+
name = test["name"]
|
|
1340
|
+
|
|
1341
|
+
# This takes into account that for mozilla-specific WPT tests, the path
|
|
1342
|
+
# contains an extra '/_mozilla' prefix that must be accounted for.
|
|
1343
|
+
if name.startswith("/_mozilla"):
|
|
1344
|
+
depth = depth + 1
|
|
1345
|
+
|
|
1346
|
+
# Webdriver tests are nested in "classic" and "bidi" folders. Increase
|
|
1347
|
+
# the depth to avoid grouping all classic or bidi tests in one chunk.
|
|
1348
|
+
if name.startswith(("/webdriver", "/_mozilla/webdriver")):
|
|
1349
|
+
depth = depth + 1
|
|
1350
|
+
|
|
1351
|
+
# Webdriver BiDi tests are nested even further as tests are grouped by
|
|
1352
|
+
# module but also by command / event name.
|
|
1353
|
+
if name.startswith(("/webdriver/tests/bidi", "/_mozilla/webdriver/bidi")):
|
|
1354
|
+
depth = depth + 1
|
|
1355
|
+
|
|
1356
|
+
# wpt canvas tests are mostly nested under subfolders of /html/canvas,
|
|
1357
|
+
# increase the depth to ensure chunks can be balanced correctly.
|
|
1358
|
+
if name.startswith("/html/canvas"):
|
|
1359
|
+
depth = depth + 1
|
|
1360
|
+
|
|
1361
|
+
if name.startswith("/_mozilla/webgpu"):
|
|
1362
|
+
depth = 9001
|
|
1363
|
+
|
|
1364
|
+
# We have a leading / so the first component is always ""
|
|
1365
|
+
components = depth + 1
|
|
1366
|
+
|
|
1367
|
+
path = name.split("?", 1)[0].split("#", 1)[0]
|
|
1368
|
+
return "/".join(path.rsplit("/", 1)[0].split("/")[:components])
|
|
1369
|
+
|
|
1370
|
+
def add_wpt_manifest_data(self):
|
|
1371
|
+
"""Adds manifest data for web-platform-tests into the list of available tests.
|
|
1372
|
+
|
|
1373
|
+
Upon invocation, this method will download from firefox-ci the most recent
|
|
1374
|
+
version of the web-platform-tests manifests.
|
|
1375
|
+
|
|
1376
|
+
Once manifest is downloaded, this method will add details about each test
|
|
1377
|
+
into the list of available tests.
|
|
1378
|
+
"""
|
|
1379
|
+
if self._wpt_loaded:
|
|
1380
|
+
return
|
|
1381
|
+
|
|
1382
|
+
self._reset_state()
|
|
1383
|
+
|
|
1384
|
+
wpt_path = os.path.join(self.topsrcdir, "testing", "web-platform")
|
|
1385
|
+
old_path = sys.path[:]
|
|
1386
|
+
sys.path = [wpt_path] + sys.path
|
|
1387
|
+
|
|
1388
|
+
import logging
|
|
1389
|
+
|
|
1390
|
+
import manifestupdate
|
|
1391
|
+
|
|
1392
|
+
logger = logging.getLogger("manifestupdate")
|
|
1393
|
+
logger.disabled = True
|
|
1394
|
+
|
|
1395
|
+
manifests = manifestupdate.run(
|
|
1396
|
+
self.topsrcdir,
|
|
1397
|
+
self.topobjdir,
|
|
1398
|
+
rebuild=False,
|
|
1399
|
+
config_path=None,
|
|
1400
|
+
rewrite_config=True,
|
|
1401
|
+
update=True,
|
|
1402
|
+
logger=logger,
|
|
1403
|
+
)
|
|
1404
|
+
|
|
1405
|
+
sys.path = old_path
|
|
1406
|
+
|
|
1407
|
+
if not manifests:
|
|
1408
|
+
print("Loading wpt manifest failed")
|
|
1409
|
+
return
|
|
1410
|
+
|
|
1411
|
+
for manifest, data in manifests.items():
|
|
1412
|
+
tests_root = data[
|
|
1413
|
+
"tests_path"
|
|
1414
|
+
] # full path on disk until web-platform tests directory
|
|
1415
|
+
|
|
1416
|
+
for test_type, path, tests in manifest:
|
|
1417
|
+
if test_type not in WPT_TYPES:
|
|
1418
|
+
continue
|
|
1419
|
+
|
|
1420
|
+
full_path = mozpath.join(tests_root, path) # absolute path on disk
|
|
1421
|
+
src_path = mozpath.relpath(full_path, self.topsrcdir)
|
|
1422
|
+
test_tags = self.get_test_tags([], data.get("metadata_path", ""), path)
|
|
1423
|
+
|
|
1424
|
+
for test in tests:
|
|
1425
|
+
testobj = {
|
|
1426
|
+
"head": "",
|
|
1427
|
+
"support-files": "",
|
|
1428
|
+
"path": full_path,
|
|
1429
|
+
"flavor": "web-platform-tests",
|
|
1430
|
+
"subsuite": test_type,
|
|
1431
|
+
"here": mozpath.dirname(path),
|
|
1432
|
+
"name": test.id,
|
|
1433
|
+
"file_relpath": src_path,
|
|
1434
|
+
"srcdir_relpath": src_path,
|
|
1435
|
+
"dir_relpath": mozpath.dirname(src_path),
|
|
1436
|
+
"tags": " ".join(test_tags),
|
|
1437
|
+
}
|
|
1438
|
+
group = self.get_wpt_group(testobj)
|
|
1439
|
+
testobj["manifest"] = group
|
|
1440
|
+
|
|
1441
|
+
test_root = "tests"
|
|
1442
|
+
if group.startswith("/_mozilla"):
|
|
1443
|
+
test_root = os.path.join("mozilla", "tests")
|
|
1444
|
+
group = group[len("/_mozilla") :]
|
|
1445
|
+
|
|
1446
|
+
group = group.lstrip("/")
|
|
1447
|
+
testobj["manifest_relpath"] = os.path.join(
|
|
1448
|
+
wpt_path, test_root, group
|
|
1449
|
+
)
|
|
1450
|
+
self._tests.append(testobj)
|
|
1451
|
+
|
|
1452
|
+
self._wpt_loaded = True
|
|
1453
|
+
|
|
1454
|
+
def resolve_tests(self, cwd=None, **kwargs):
|
|
1455
|
+
"""Resolve tests from an identifier.
|
|
1456
|
+
|
|
1457
|
+
This is a generator of dicts describing each test. All arguments are
|
|
1458
|
+
optional.
|
|
1459
|
+
|
|
1460
|
+
Paths in returned tests are automatically translated to the paths in
|
|
1461
|
+
the _tests directory under the object directory.
|
|
1462
|
+
|
|
1463
|
+
Args:
|
|
1464
|
+
cwd (str):
|
|
1465
|
+
If specified, we will limit our results to tests under this
|
|
1466
|
+
directory. The directory should be defined as an absolute path
|
|
1467
|
+
under topsrcdir or topobjdir.
|
|
1468
|
+
|
|
1469
|
+
paths (list):
|
|
1470
|
+
An iterable of values to use to identify tests to run. If an
|
|
1471
|
+
entry is a known test file, tests associated with that file are
|
|
1472
|
+
returned (there may be multiple configurations for a single
|
|
1473
|
+
file). If an entry is a directory, or a prefix of a directory
|
|
1474
|
+
containing tests, all tests in that directory are returned. If
|
|
1475
|
+
the string appears in a known test file, that test file is
|
|
1476
|
+
considered. If the path contains a wildcard pattern, tests
|
|
1477
|
+
matching that pattern are returned.
|
|
1478
|
+
|
|
1479
|
+
under_path (str):
|
|
1480
|
+
If specified, will be used to filter out tests that aren't in
|
|
1481
|
+
the specified path prefix relative to topsrcdir or the test's
|
|
1482
|
+
installed dir.
|
|
1483
|
+
|
|
1484
|
+
flavor (str):
|
|
1485
|
+
If specified, will be used to filter returned tests to only be
|
|
1486
|
+
the flavor specified. A flavor is something like ``xpcshell``.
|
|
1487
|
+
|
|
1488
|
+
subsuite (str):
|
|
1489
|
+
If specified will be used to filter returned tests to only be
|
|
1490
|
+
in the subsuite specified. To filter only tests that *don't*
|
|
1491
|
+
have any subsuite, pass the string 'undefined'.
|
|
1492
|
+
|
|
1493
|
+
tags (list):
|
|
1494
|
+
If specified, will be used to filter out tests that don't contain
|
|
1495
|
+
a matching tag.
|
|
1496
|
+
"""
|
|
1497
|
+
if cwd:
|
|
1498
|
+
norm_cwd = mozpath.normpath(cwd)
|
|
1499
|
+
norm_srcdir = mozpath.normpath(self.topsrcdir)
|
|
1500
|
+
norm_objdir = mozpath.normpath(self.topobjdir)
|
|
1501
|
+
|
|
1502
|
+
reldir = None
|
|
1503
|
+
|
|
1504
|
+
if norm_cwd.startswith(norm_objdir):
|
|
1505
|
+
reldir = norm_cwd[len(norm_objdir) + 1 :]
|
|
1506
|
+
elif norm_cwd.startswith(norm_srcdir):
|
|
1507
|
+
reldir = norm_cwd[len(norm_srcdir) + 1 :]
|
|
1508
|
+
|
|
1509
|
+
kwargs["under_path"] = reldir
|
|
1510
|
+
|
|
1511
|
+
rewrite_base = None
|
|
1512
|
+
for test in self._resolve(**kwargs):
|
|
1513
|
+
rewrite_base = self.test_rewrites.get(test["flavor"], None)
|
|
1514
|
+
|
|
1515
|
+
if rewrite_base:
|
|
1516
|
+
rewrite_base = os.path.join(
|
|
1517
|
+
self.topobjdir, os.path.normpath(rewrite_base)
|
|
1518
|
+
)
|
|
1519
|
+
yield rewrite_test_base(test, rewrite_base)
|
|
1520
|
+
else:
|
|
1521
|
+
yield test
|
|
1522
|
+
|
|
1523
|
+
@staticmethod
|
|
1524
|
+
@cache
|
|
1525
|
+
def _path_to_suite():
|
|
1526
|
+
"""Build a reverse map from root_path to suite name from TEST_SUITES."""
|
|
1527
|
+
return {
|
|
1528
|
+
v["root_path"]: suite
|
|
1529
|
+
for suite, v in TEST_SUITES.items()
|
|
1530
|
+
if "root_path" in v
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
def resolve_metadata(self, what):
|
|
1534
|
+
"""Resolve tests based on the given metadata. If not specified, metadata
|
|
1535
|
+
from outgoing files will be used instead.
|
|
1536
|
+
"""
|
|
1537
|
+
# Parse arguments and assemble a test "plan."
|
|
1538
|
+
run_suites = set()
|
|
1539
|
+
run_tests = []
|
|
1540
|
+
|
|
1541
|
+
for entry in what:
|
|
1542
|
+
# If the path matches the name or alias of an entire suite, run
|
|
1543
|
+
# the entire suite.
|
|
1544
|
+
if entry in TEST_SUITES:
|
|
1545
|
+
run_suites.add(entry)
|
|
1546
|
+
continue
|
|
1547
|
+
suitefound = False
|
|
1548
|
+
for suite, v in TEST_SUITES.items():
|
|
1549
|
+
if entry.lower() in v.get("aliases", []):
|
|
1550
|
+
run_suites.add(suite)
|
|
1551
|
+
suitefound = True
|
|
1552
|
+
if suitefound:
|
|
1553
|
+
continue
|
|
1554
|
+
|
|
1555
|
+
# If the path matches a suite's root_path, resolve it as a suite
|
|
1556
|
+
# rather than enumerating individual test files.
|
|
1557
|
+
relpath = self._wrap_path_argument(entry).relpath()
|
|
1558
|
+
suite_name = self._path_to_suite().get(mozpath.normpath(relpath))
|
|
1559
|
+
if suite_name:
|
|
1560
|
+
run_suites.add(suite_name)
|
|
1561
|
+
continue
|
|
1562
|
+
|
|
1563
|
+
# Now look for file/directory matches in the TestResolver.
|
|
1564
|
+
# since either path or tag can be defined (but not both), here we assume
|
|
1565
|
+
# one or none are defined, but not both
|
|
1566
|
+
tests = list(self.resolve_tests(paths=[relpath]))
|
|
1567
|
+
if not tests:
|
|
1568
|
+
tests = list(self.resolve_tests(tags=[entry]))
|
|
1569
|
+
run_tests.extend(tests)
|
|
1570
|
+
|
|
1571
|
+
if not tests:
|
|
1572
|
+
print("UNKNOWN TEST: %s" % entry, file=sys.stderr)
|
|
1573
|
+
|
|
1574
|
+
return run_suites, run_tests
|