#!/usr/bin/env python # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. import json import os import re import sys import urllib.request from html import escape as html_escape TASKCLUSTER_ROOT_URL = "https://community-tc.services.mozilla.com" def fetch(url): url = TASKCLUSTER_ROOT_URL + "/api/" + url print("Fetching " + url) response = urllib.request.urlopen(url) assert response.getcode() == 200 return response def fetch_json(url): with fetch(url) as response: return json.load(response) def task(platform, chunk, key): return "index/v1/task/project.servo.%s_wpt_%s.%s" % (platform, chunk, key) def failing_reftests(platform, key): chunk_1_task_id = fetch_json(task(platform, 1, key))["taskId"] name = fetch_json("queue/v1/task/" + chunk_1_task_id)["metadata"]["name"] match = re.search("WPT chunk (\d+) / (\d+)", name) assert match.group(1) == "1" total_chunks = int(match.group(2)) for chunk in range(1, total_chunks + 1): with fetch(task(platform, chunk, key) + "/artifacts/public/test-wpt.log") as response: for line in response: message = json.loads(line) if message.get("status") not in {None, "OK", "PASS"}: screenshots = message.get("extra", {}).get("reftest_screenshots") if screenshots: yield message["test"], screenshots def main(index_key, commit_sha): failures_2013 = {url for url, _ in failing_reftests("linux_x64", index_key)} failures_2020 = Directory() for url, screenshots in failing_reftests("linux_x64_2020", index_key): if url not in failures_2013: assert url.startswith("/") failures_2020.add(url[1:], screenshots) here = os.path.dirname(__file__) with open(os.path.join(here, "prism.js")) as f: prism_js = f.read() with open(os.path.join(here, "prism.css")) as f: prism_css = f.read() with open(os.path.join(here, "regressions.html"), "w", encoding="utf-8") as html: os.chdir(os.path.join(here, "../../tests/wpt")) html.write("""
%s
%s
\n" % k)
if isinstance(v, Directory):
html.write("%s\n" % v.count)
v.write(html)
else:
a, rel, b = v
html.write("%s
%s %s
%s
\n" % src)
html.write("\n")
html.write("\n")
if __name__ == "__main__":
sys.exit(main(*sys.argv[1:]))