Skip to content

Commit 8843094

Browse files
committedMay 17, 2024
Bug 1897403 - Handle wpt test id as a URL when computing group name, r=Sasha
wpt test ids are URLs, and can have query components. This means that using `os.path.dirname` isn't a correct way to extract different parts of the URL In particular a test id like `/foo/bar/baz?foobar=sp/am` can lead to an invalid group name like `foo/bar/baz?foobar=sp`, which breaks the invariant that we can turn the group name into a filesystem path that may contain a __dir__.ini file with metadata for that group. The fix here is to correctly treat the test id as a URL using the same logic as in wptrunner. Differential Revision: https://phabricator.services.mozilla.com/D210783
1 parent 29317f5 commit 8843094

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎testing/mozbase/moztest/moztest/resolve.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
from abc import ABCMeta, abstractmethod
1010
from collections import defaultdict
11+
from urllib.parse import urlsplit
1112

1213
import mozpack.path as mozpath
1314
import six
@@ -853,10 +854,9 @@ def get_wpt_group(self, test, depth=3):
853854
if test["name"].startswith("/_mozilla/webgpu"):
854855
depth = 9001
855856

856-
group = os.path.dirname(test["name"])
857-
while group.count("/") > depth:
858-
group = os.path.dirname(group)
859-
return group
857+
# We have a leading / so the first component is always ""
858+
components = depth + 1
859+
return "/".join(urlsplit(test["name"]).path.split("/")[:-1][:components])
860860

861861
def add_wpt_manifest_data(self):
862862
"""Adds manifest data for web-platform-tests into the list of available tests.

0 commit comments

Comments
 (0)
Please sign in to comment.