Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions bugbug/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,4 +1003,32 @@ def collect_support_files(value):
if f.is_file()
)

# If a web-platform test or meta is modified, run the relevant web-platform folder.
if not any(path.endswith(ignore) for ignore in ("/META.yml", "/README.md")):
for base in ("testing/web-platform/mozilla", "testing/web-platform"):
if path.startswith(f"{base}/meta/") or path.startswith(
f"{base}/tests/"
):
sub = "meta" if "/meta/" in path else "tests"

relative = Path(path).relative_to(f"{base}/{sub}")

test_root = repo_dir / base / "tests"
cur_dir = test_root / relative.parent

def has_html_files(d: Path) -> bool:
return any(p.suffix.lower() == ".html" for p in d.iterdir())

while cur_dir != test_root and not has_html_files(cur_dir):
cur_dir = cur_dir.parent

# Ignore files in top level "meta" or "tests".
if len(cur_dir.parts) == 1:
break

if has_html_files(cur_dir):
manifests.add(str(cur_dir.relative_to(repo_dir)))

break

return manifests
75 changes: 75 additions & 0 deletions tests/test_test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,3 +1114,78 @@ def test_find_manifests_for_paths(tmp_path) -> None:
assert test_scheduling.find_manifests_for_paths(
str(tmp_path), ["absolute_path_with_subdirglob/subdir/asd.js"]
) == {"test/chrome.toml"}

(tmp_path / "testing/web-platform/tests/html/semantics").mkdir(parents=True)
(tmp_path / "testing/web-platform/tests/.gitignore").touch()
(
tmp_path
/ "testing/web-platform/tests/html/semantics/rellist-feature-detection.html"
).touch()
(tmp_path / "testing/web-platform/tests/html/semantics/META.yml").touch()
(tmp_path / "testing/web-platform/tests/html/semantics/interactive-elements").mkdir(
parents=True
)
(
tmp_path
/ "testing/web-platform/tests/html/semantics/interactive-elements"
/ "contextmenu-historical.html"
).touch()
(tmp_path / "testing/web-platform/mozilla/meta/pointerevents").mkdir(parents=True)
(
tmp_path
/ "testing/web-platform/mozilla/meta/pointerevents/pointerevent_click_during_parent_capture.html.ini"
).touch()
(tmp_path / "testing/web-platform/mozilla/tests/pointerevents").mkdir(parents=True)
(
tmp_path
/ "testing/web-platform/mozilla/tests/pointerevents/pointerevent_click_during_parent_capture.html"
).touch()
(tmp_path / "testing/web-platform/tests/encrypted-media/content").mkdir(
parents=True
)
(
tmp_path
/ "testing/web-platform/tests/encrypted-media/clearkey-events.https.html"
).touch()
(
tmp_path
/ "testing/web-platform/tests/encrypted-media/content/content-metadata.js"
).touch()

assert (
test_scheduling.find_manifests_for_paths(
str(tmp_path), ["testing/web-platform/tests/.gitignore"]
)
== set()
)

assert test_scheduling.find_manifests_for_paths(
str(tmp_path),
["testing/web-platform/tests/html/semantics/rellist-feature-detection.html"],
) == {"testing/web-platform/tests/html/semantics"}

assert (
test_scheduling.find_manifests_for_paths(
str(tmp_path), ["testing/web-platform/tests/html/semantics/META.yml"]
)
== set()
)

assert test_scheduling.find_manifests_for_paths(
str(tmp_path),
[
"testing/web-platform/tests/html/semantics/interactive-elements/contextmenu-historical.html"
],
) == {"testing/web-platform/tests/html/semantics/interactive-elements"}

assert test_scheduling.find_manifests_for_paths(
str(tmp_path),
[
"testing/web-platform/mozilla/meta/pointerevents/pointerevent_click_during_parent_capture.html.ini"
],
) == {"testing/web-platform/mozilla/tests/pointerevents"}

assert test_scheduling.find_manifests_for_paths(
str(tmp_path),
["testing/web-platform/tests/encrypted-media/content/content-metadata.js"],
) == {"testing/web-platform/tests/encrypted-media"}