Bug 1735829 [wpt PR 31243] - Add an update-built wpt command, a=testonly
[gecko.git] / testing / web-platform / tests / tools / ci / update_built.py
blobff377a2513adc63b7b6a36566845d78d7e3b173e
1 import logging
2 import os
3 import subprocess
4 from argparse import ArgumentParser
6 logger = logging.getLogger()
8 wpt_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
10 scripts = {
11 "canvas": ["html/canvas/tools/gentest.py"],
12 "conformance-checkers": ["conformance-checkers/tools/dl.py",
13 "conformance-checkers/tools/ins-del-datetime.py",
14 "conformance-checkers/tools/picture.py",
15 "conformance-checkers/tools/url.py"],
16 "css-ui": ["css/css-ui/tools/appearance-build-webkit-reftests.py"],
17 "html5lib": ["html/tools/update_html5lib_tests.py"],
18 "infrastructure": ["infrastructure/assumptions/tools/ahem-generate-table.py"],
19 "mimesniff": ["mimesniff/mime-types/resources/generated-mime-types.py"],
20 "speculative-parsing": ["html/syntax/speculative-parsing/tools/generate.py"]
24 def get_parser():
25 parser = ArgumentParser()
26 parser.add_argument("--list", action="store_true",
27 help="List suites that can be updated and the related script files")
28 parser.add_argument("--include", nargs="*", choices=scripts.keys(), default=None,
29 help="Suites to update (default is to update everything)")
30 return parser
33 def list_suites(include):
34 for name, script_paths in scripts.items():
35 if name in include:
36 print(name)
37 for script_path in script_paths:
38 print(f" {script_path}")
41 def run(venv, **kwargs):
42 include = kwargs["include"]
43 if include is None:
44 include = list(scripts.keys())
46 if kwargs["list"]:
47 list_suites(include)
48 return 0
50 failed = False
52 for target in include:
53 for script in scripts[target]:
54 script_path = script.replace("/", os.path.sep)
55 cmd = [os.path.join(venv.bin_path, "python3"), os.path.join(wpt_root, script_path)]
56 logger.info(f"Running {' '.join(cmd)}")
57 try:
58 subprocess.check_call(cmd, cwd=os.path.dirname(script_path))
59 except subprocess.CalledProcessError:
60 logger.error(f"Update script {script} failed")
61 failed = True
63 return 1 if failed else 0