diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/tools/manifest/update.py | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/tools/manifest/update.py')
-rwxr-xr-x | testing/web-platform/tests/tools/manifest/update.py | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/manifest/update.py b/testing/web-platform/tests/tools/manifest/update.py new file mode 100755 index 0000000000..d7ef2082eb --- /dev/null +++ b/testing/web-platform/tests/tools/manifest/update.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python3 +import argparse +import os + +from . import manifest +from . import vcs +from .log import get_logger, enable_debug_logging +from .download import download_from_github + +here = os.path.dirname(__file__) + +wpt_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir)) + +logger = get_logger() + +MYPY = False +if MYPY: + # MYPY is set to True when run under Mypy. + from typing import Any + from typing import Optional + from .manifest import Manifest # avoid cyclic import + + +def update(tests_root, # type: str + manifest, # type: Manifest + manifest_path=None, # type: Optional[str] + working_copy=True, # type: bool + cache_root=None, # type: Optional[str] + rebuild=False, # type: bool + parallel=True # type: bool + ): + # type: (...) -> bool + logger.warning("Deprecated; use manifest.load_and_update instead") + logger.info("Updating manifest") + + tree = vcs.get_tree(tests_root, manifest, manifest_path, cache_root, + working_copy, rebuild) + return manifest.update(tree, parallel) + + +def update_from_cli(**kwargs): + # type: (**Any) -> None + tests_root = kwargs["tests_root"] + path = kwargs["path"] + assert tests_root is not None + + if not kwargs["rebuild"] and kwargs["download"]: + download_from_github(path, tests_root) + + manifest.load_and_update(tests_root, + path, + kwargs["url_base"], + update=True, + rebuild=kwargs["rebuild"], + cache_root=kwargs["cache_root"], + parallel=kwargs["parallel"]) + + +def abs_path(path): + # type: (str) -> str + return os.path.abspath(os.path.expanduser(path)) + + +def create_parser(): + # type: () -> argparse.ArgumentParser + parser = argparse.ArgumentParser() + parser.add_argument( + "-v", "--verbose", dest="verbose", action="store_true", default=False, + help="Turn on verbose logging") + parser.add_argument( + "-p", "--path", type=abs_path, help="Path to manifest file.") + parser.add_argument( + "--tests-root", type=abs_path, default=wpt_root, help="Path to root of tests.") + parser.add_argument( + "-r", "--rebuild", action="store_true", default=False, + help="Force a full rebuild of the manifest.") + parser.add_argument( + "--url-base", action="store", default="/", + help="Base url to use as the mount point for tests in this manifest.") + parser.add_argument( + "--no-download", dest="download", action="store_false", default=True, + help="Never attempt to download the manifest.") + parser.add_argument( + "--cache-root", action="store", default=os.path.join(wpt_root, ".wptcache"), + help="Path in which to store any caches (default <tests_root>/.wptcache/)") + parser.add_argument( + "--no-parallel", dest="parallel", action="store_false", default=True, + help="Do not parallelize building the manifest") + return parser + + +def run(*args, **kwargs): + # type: (*Any, **Any) -> None + if kwargs["path"] is None: + kwargs["path"] = os.path.join(kwargs["tests_root"], "MANIFEST.json") + if kwargs["verbose"]: + enable_debug_logging() + update_from_cli(**kwargs) + + +def main(): + # type: () -> None + opts = create_parser().parse_args() + + run(**vars(opts)) |