Skip to content

Instantly share code, notes, and snippets.

@bplaat
Created March 26, 2024 17:35
Show Gist options
  • Save bplaat/5877108393c5737a5a8071f97bfae47f to your computer and use it in GitHub Desktop.
Save bplaat/5877108393c5737a5a8071f97bfae47f to your computer and use it in GitHub Desktop.
Simple WPT tests runner script for Ladybird
#!/usr/bin/env python3
# Simple WPT tests runner script for Ladybird
# Usage: ./wpt-runner.py dom/
import subprocess
import sys
import requests
from bs4 import BeautifulSoup
bin_path = "Build/lagom/bin/Ladybird.app/Contents/MacOS"
def run_test(path):
print(f"Running {path}")
command = [f"{bin_path}/headless-browser", "-d", f"http://wpt.live/{path}"]
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
stdout = stdout.decode()
stderr = stderr.decode()
if process.returncode != 0 or 'span.ok' not in stdout:
print(stderr)
sys.exit(1)
def run_folder(path):
if not path.endswith('/'):
path = f"{path}/"
print(f"Indexing {path}")
response = requests.get(f"http://wpt.live/{path}")
soup = BeautifulSoup(response.text, "html.parser")
for link in soup.find_all("a"):
href = link.get("href")
if href and href != "/" and link.text != ".." and link.text != "support":
if href.endswith("/"):
run_folder(f"{path}{href}")
if href.endswith(".htm") or href.endswith(".html"):
run_test(f"{path}{href}")
if __name__ == "__main__":
run_folder(sys.argv[1] if len(sys.argv) > 1 else "dom/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment