tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

update_manifest.py (1308B)


      1 # mypy: ignore-errors
      2 
      3 import json
      4 import os
      5 
      6 from tools.wpt.utils import load_source
      7 
      8 here = os.path.dirname(__file__)
      9 localpaths = load_source("localpaths", os.path.abspath(os.path.join(here, os.pardir, "localpaths.py")))
     10 
     11 root = localpaths.repo_root
     12 
     13 from manifest import manifest
     14 
     15 
     16 def main(request, response):
     17    path = os.path.join(root, "MANIFEST.json")
     18 
     19    # TODO make this download rather than rebuilding from scratch when possible
     20    manifest_file = manifest.load_and_update(root, path, "/", parallel=False)
     21 
     22    supported_types = ["testharness", "reftest", "manual"]
     23    data = {"items": {},
     24            "url_base": "/"}
     25    for item_type in supported_types:
     26        data["items"][item_type] = {}
     27    for item_type, path, tests in manifest_file.itertypes(*supported_types):
     28        tests_data = []
     29        for item in tests:
     30            test_data = [item.url[1:]]
     31            if item_type == "reftest":
     32                test_data.append(item.references)
     33            test_data.append({})
     34            if item_type != "manual":
     35                test_data[-1]["timeout"] = item.timeout
     36            tests_data.append(test_data)
     37        assert path not in data["items"][item_type]
     38        data["items"][item_type][path] = tests_data
     39 
     40    return [("Content-Type", "application/json")], json.dumps(data)