From 77f8bd9cae6c27987d9aec927b32553cd878e679 Mon Sep 17 00:00:00 2001 From: Geoffrey Sneddon Date: Fri, 6 Nov 2015 12:16:36 +0000 Subject: [PATCH] Fix the previous commit to actually handle multiple URLs --- wptrunner/manifestinclude.py | 43 +++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/wptrunner/manifestinclude.py b/wptrunner/manifestinclude.py index 07e69325b5ca23..d9b4ee455a6d06 100644 --- a/wptrunner/manifestinclude.py +++ b/wptrunner/manifestinclude.py @@ -91,29 +91,36 @@ def _add_rule(self, test_manifests, url, direction): variant += "?" + query maybe_path = os.path.join(rest, last) - - for path in glob.iglob(maybe_path): - for manifest, data in test_manifests.iteritems(): - rel_path = os.path.relpath(path, data["tests_path"]) - if ".." not in rel_path.split(os.sep): - url = data["url_base"] + rel_path.replace(os.path.sep, "/") + variant - break + paths = glob.glob(maybe_path) + + if paths: + urls = [] + for path in paths: + for manifest, data in test_manifests.iteritems(): + rel_path = os.path.relpath(path, data["tests_path"]) + if ".." not in rel_path.split(os.sep): + urls.append(data["url_base"] + rel_path.replace(os.path.sep, "/") + variant) + break + else: + urls = [url] assert direction in ("include", "exclude") - components = self._get_components(url) - node = self - while components: - component = components.pop() - if component not in node.child_map: - new_node = IncludeManifest(DataNode(component)) - node.append(new_node) - new_node.set("skip", node.get("skip", {})) + for url in urls: + components = self._get_components(url) + + node = self + while components: + component = components.pop() + if component not in node.child_map: + new_node = IncludeManifest(DataNode(component)) + node.append(new_node) + new_node.set("skip", node.get("skip", {})) - node = node.child_map[component] + node = node.child_map[component] - skip = False if direction == "include" else True - node.set("skip", str(skip)) + skip = False if direction == "include" else True + node.set("skip", str(skip)) def add_include(self, test_manifests, url_prefix): """Add a rule indicating that tests under a url path