4 from typing
import Any
, Optional
, Text
7 from .manifest
import compute_manifest_spec_items
, InvalidCacheError
, Manifest
, write
8 from .log
import get_logger
, enable_debug_logging
11 here
= os
.path
.dirname(__file__
)
13 wpt_root
= os
.path
.abspath(os
.path
.join(here
, os
.pardir
, os
.pardir
))
18 def update_spec(tests_root
: Text
,
21 cache_root
: Optional
[Text
] = None,
22 working_copy
: bool = True,
26 manifest
= Manifest(tests_root
, url_base
)
28 logger
.info("Updating SPEC_MANIFEST")
30 tree
= vcs
.get_tree(tests_root
, manifest
, manifest_path
, cache_root
,
32 changed
= manifest
.update(tree
, parallel
, compute_manifest_spec_items
)
33 except InvalidCacheError
:
34 logger
.error("Manifest cache in spec.py was invalid.")
38 write(manifest
, manifest_path
)
42 def update_from_cli(**kwargs
: Any
) -> None:
43 tests_root
= kwargs
["tests_root"]
45 assert tests_root
is not None
47 update_spec(tests_root
,
50 cache_root
=kwargs
["cache_root"],
51 parallel
=kwargs
["parallel"])
54 def abs_path(path
: str) -> str:
55 return os
.path
.abspath(os
.path
.expanduser(path
))
58 def create_parser() -> argparse
.ArgumentParser
:
59 parser
= argparse
.ArgumentParser()
61 "-v", "--verbose", dest
="verbose", action
="store_true", default
=False,
62 help="Turn on verbose logging")
64 "-p", "--path", type=abs_path
, help="Path to manifest file.")
66 "--tests-root", type=abs_path
, default
=wpt_root
, help="Path to root of tests.")
68 "--url-base", action
="store", default
="/",
69 help="Base url to use as the mount point for tests in this manifest.")
71 "--cache-root", action
="store", default
=os
.path
.join(wpt_root
, ".wptcache"),
72 help="Path in which to store any caches (default <tests_root>/.wptcache/)")
74 "--no-parallel", dest
="parallel", action
="store_false", default
=True,
75 help="Do not parallelize building the manifest")
79 def run(*args
: Any
, **kwargs
: Any
) -> None:
80 if kwargs
["path"] is None:
81 kwargs
["path"] = os
.path
.join(kwargs
["tests_root"], "SPEC_MANIFEST.json")
83 enable_debug_logging()
84 update_from_cli(**kwargs
)