Skip to content

Commit

Permalink
Merge pull request #156 from gsnedders/glob_paths_fix
Browse files Browse the repository at this point in the history
Fix the previous commit to actually handle multiple URLs
  • Loading branch information
jgraham committed Nov 6, 2015
2 parents de53aee + 77f8bd9 commit 02bcaf8
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions wptrunner/manifestinclude.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 02bcaf8

Please sign in to comment.