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
This commit is contained in:
James Graham 2024-05-17 17:52:41 +00:00
parent 29317f50a4
commit 8843094dda

View file

@ -8,6 +8,7 @@ import pickle
import sys
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from urllib.parse import urlsplit
import mozpack.path as mozpath
import six
@ -853,10 +854,9 @@ class TestResolver(MozbuildObject):
if test["name"].startswith("/_mozilla/webgpu"):
depth = 9001
group = os.path.dirname(test["name"])
while group.count("/") > depth:
group = os.path.dirname(group)
return group
# We have a leading / so the first component is always ""
components = depth + 1
return "/".join(urlsplit(test["name"]).path.split("/")[:-1][:components])
def add_wpt_manifest_data(self):
"""Adds manifest data for web-platform-tests into the list of available tests.