Bug 1634551 - [taskgraph] Move WPT group assignment into the TestResolver, r=egao
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 20 May 2020 17:51:20 +0000
changeset 531302 c271cdf24dd59ba81b6c5948f796132fcd906e0c
parent 531301 a94271c84318acba14a63c52ba98afe512b071f7
child 531303 0356e5fff183afb22f6eeca0e53ab8ec56745fad
push id37437
push usernerli@mozilla.com
push dateThu, 21 May 2020 02:34:41 +0000
treeherdermozilla-central@3d91ba9e1d25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersegao
bugs1634551
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
taskcluster/taskgraph/util/chunking.py
testing/mozbase/moztest/moztest/resolve.py
--- a/taskcluster/taskgraph/util/chunking.py
+++ b/taskcluster/taskgraph/util/chunking.py
@@ -93,23 +93,17 @@ def tests_by_top_directory(tests, depth)
         path = os.path.dirname(t['name'])
         # Remove path elements beyond depth of 3, because WPT harness uses
         # --run-by-dir=3 by convention in Mozilla CI.
         # Note, this means /_mozilla tests retain an effective depth of 2 due to
         # the extra prefix element.
         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
 
 
 @memoize
 def get_chunked_manifests(flavor, subsuite, chunks, mozinfo):
     """Compute which manifests should run in which chunks with the given category
     of tests.
 
@@ -125,17 +119,17 @@ def get_chunked_manifests(flavor, subsui
         A list of manifests where each item contains the manifest that should
         run in the corresponding chunk.
     """
     mozinfo = dict(mozinfo)
     # Compute all tests for the given suite/subsuite.
     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'])
         runtimes = [(k, v) for k, v in runtimes.items()
                     if k.startswith('/') and not os.path.splitext(k)[-1]]
 
         # Keep track of test paths for each chunk, and the runtime information.
         chunked_manifests = [[[], 0] for _ in range(chunks)]
--- a/testing/mozbase/moztest/moztest/resolve.py
+++ b/testing/mozbase/moztest/moztest/resolve.py
@@ -687,16 +687,32 @@ class TestResolver(MozbuildObject):
         if path is None:
             return True
         if mozpath.match(path, "testing/web-platform/tests/**"):
             return True
         if mozpath.match(path, "testing/web-platform/mozilla/tests/**"):
             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.
 
         Upon invocation, this method will download from firefox-ci the most recent
         version of the web-platform-tests manifests.
 
         Once manifest is downloaded, this method will add details about each test
         into the list of available tests.
@@ -728,30 +744,39 @@ class TestResolver(MozbuildObject):
                 src_path = mozpath.relpath(full_path, self.topsrcdir)
                 if test_type not in ["testharness", "reftest", "wdspec", "crashtest"]:
                     continue
 
                 full_path = mozpath.join(tests_root, path)  # absolute path on disk
                 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
 
     def resolve_tests(self, cwd=None, **kwargs):
         """Resolve tests from an identifier.
 
         This is a generator of dicts describing each test. All arguments are
         optional.