Bug 1369471 - Allow running wpt directories by path on the command line, r=maja_zf draft
authorJames Graham <james@hoppipolla.co.uk>
Thu, 01 Jun 2017 19:01:01 +0100
changeset 587807 5c010031f867afe239c52715012b602ecf3a0232
parent 587503 bdb2387396b4a74dfefb7c983733eed3625e906a
child 631370 f650493844d7022ad56eb15f678d94e36365070c
push id61815
push userbmo:james@hoppipolla.co.uk
push dateThu, 01 Jun 2017 18:09:09 +0000
reviewersmaja_zf
bugs1369471
milestone55.0a1
Bug 1369471 - Allow running wpt directories by path on the command line, r=maja_zf We regressed running entire directories when wptrunner was switched to look up command parameters directly in the manifest rather than iterating over prefix matches. For files that's OK, but for directories the old behaviour is required. MozReview-Commit-ID: HVL7rL1YuZx
testing/web-platform/tests/tools/manifest/manifest.py
testing/web-platform/tests/tools/wptrunner/wptrunner/manifestinclude.py
--- a/testing/web-platform/tests/tools/manifest/manifest.py
+++ b/testing/web-platform/tests/tools/manifest/manifest.py
@@ -46,16 +46,25 @@ class Manifest(object):
             for path, tests in sorted(iteritems(self._data[item_type])):
                 yield item_type, path, tests
 
     def iterpath(self, path):
         for type_tests in self._data.values():
             for test in type_tests.get(path, set()):
                 yield test
 
+    def iterdir(self, dir_name):
+        if not dir_name.endswith(os.path.sep):
+            dir_name = dir_name + os.path.sep
+        for type_tests in self._data.values():
+            for path, tests in type_tests.iteritems():
+                if path.startswith(dir_name):
+                    for test in tests:
+                        yield test
+
     @property
     def reftest_nodes_by_url(self):
         if self._reftest_nodes_by_url is None:
             by_url = {}
             for path, nodes in iteritems(self._data.get("reftests", {})):
                 for node in nodes:
                     by_url[node.url] = node
             self._reftest_nodes_by_url = by_url
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/manifestinclude.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/manifestinclude.py
@@ -88,17 +88,18 @@ class IncludeManifest(ManifestItem):
         paths = glob.glob(maybe_path)
 
         if paths:
             urls = []
             for path in paths:
                 for manifest, data in test_manifests.iteritems():
                     found = False
                     rel_path = os.path.relpath(path, data["tests_path"])
-                    for test in manifest.iterpath(rel_path):
+                    iterator = manifest.iterpath if os.path.isfile(path) else manifest.iterdir
+                    for test in iterator(rel_path):
                         if not hasattr(test, "url"):
                             continue
                         url = test.url
                         if query or fragment:
                             parsed = urlparse.urlparse(url)
                             if ((query and query != parsed.query) or
                                 (fragment and fragment != parsed.fragment)):
                                 continue