Bug 1634551 - [taskgraph] Move WPT group assignment into the TestResolver, r=egao

This moves the creation of WPT groups into the TestResolver, where all kinds of
other consumers will be able to access them.

Differential Revision: https://phabricator.services.mozilla.com/D76085
This commit is contained in:
Andrew Halberstadt 2020-05-20 17:51:20 +00:00
parent df02aa6efc
commit a87fdb1bdb
2 changed files with 31 additions and 12 deletions

View File

@ -98,13 +98,7 @@ def tests_by_top_directory(tests, depth):
while path.count('/') >= depth + 1:
path = os.path.dirname(path)
# Extract the first path component (top level directory) as the key.
# This value should match the path in manifest-runtimes JSON data.
# Mozilla WPT paths have one extra URL component in the front.
components = 3 if t['name'].startswith('/_mozilla') else 2
key = '/'.join(t['name'].split('/')[:components])
results[key].append(path)
results[t["manifest"]].append(path)
return results
@ -130,7 +124,7 @@ def get_chunked_manifests(flavor, subsuite, chunks, mozinfo):
tests = get_tests(flavor, subsuite)
if flavor == 'web-platform-tests':
paths = tests_by_top_directory(tests, 3)
paths = tests_by_top_directory(tests, depth=3)
# Filter out non-web-platform-test runtime information.
runtimes = get_runtimes(mozinfo['os'])

View File

@ -692,6 +692,22 @@ class TestResolver(MozbuildObject):
return True
return False
def get_wpt_group(self, test):
"""Given a test object, set the group (aka manifest) that it belongs to.
Args:
test (dict): Test object for the particular suite and subsuite.
Returns:
str: The group the given test belongs to.
"""
# Extract the first path component (top level directory) as the key.
# This value should match the path in manifest-runtimes JSON data.
# Mozilla WPT paths have one extra URL component in the front.
components = 3 if test['name'].startswith('/_mozilla') else 2
group = '/'.join(test['name'].split('/')[:components])
return group
def add_wpt_manifest_data(self):
"""Adds manifest data for web-platform-tests into the list of available tests.
@ -733,20 +749,29 @@ class TestResolver(MozbuildObject):
src_path = mozpath.relpath(full_path, self.topsrcdir)
for test in tests:
self._tests.append({
testobj = {
"head": "",
"support-files": "",
"path": full_path,
"flavor": "web-platform-tests",
"subsuite": test_type,
"here": mozpath.dirname(path),
"manifest": mozpath.dirname(full_path),
"manifest_relpath": mozpath.dirname(src_path),
"name": test.id,
"file_relpath": src_path,
"srcdir_relpath": src_path,
"dir_relpath": mozpath.dirname(src_path),
})
}
group = self.get_wpt_group(testobj)
testobj["manifest"] = group
test_root = "tests"
if group.startswith("/_mozilla"):
test_root = os.path.join("mozilla", "tests")
group = group[len("/_mozilla"):]
group = group.lstrip("/")
testobj["manifest_relpath"] = os.path.join(wpt_path, test_root, group)
self._tests.append(testobj)
self._wpt_loaded = True