# 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 http://mozilla.org/MPL/2.0/.
import manifestdownload from mach.util import get_state_dir from mozfile import load_source from mozlog.structured import commandline from wptrunner import wptcommandline
def create_parser():
p = argparse.ArgumentParser()
p.add_argument( "--rebuild", action="store_true", help="Rebuild manifest from scratch"
)
download_group = p.add_mutually_exclusive_group()
download_group.add_argument( "--download",
dest="download",
action="store_true",
default=None,
help="Always download even if the local manifest is recent",
)
download_group.add_argument( "--no-download",
dest="download",
action="store_false",
help="Don't try to download the manifest",
)
p.add_argument( "--no-update",
action="store_false",
dest="update",
default=True,
help="Just download the manifest, don't update",
)
p.add_argument( "--config",
action="store",
dest="config_path",
default=None,
help="Path to wptrunner config file",
)
p.add_argument( "--rewrite-config",
action="store_true",
default=False,
help="Force the local configuration to be regenerated",
)
p.add_argument( "--cache-root",
action="store",
default=os.path.join(get_state_dir(), "cache", "wpt"),
help="Path to use for the metadata cache",
)
commandline.add_logging_group(p)
for paths in test_paths.values(): if isinstance(paths, dict) and"manifest_path"notin paths:
paths["manifest_path"] = os.path.join(
paths["metadata_path"], "MANIFEST.json"
)
ensure_manifest_directories(logger, test_paths)
local_config = read_local_config(os.path.join(src_wpt_dir, "wptrunner.ini")) for section in ["manifest:upstream", "manifest:mozilla"]:
url_base = local_config.get(section, "url_base")
manifest_rel_path = os.path.join(
local_config.get(section, "metadata"), "MANIFEST.json"
) if isinstance(test_paths[url_base], dict):
test_paths[url_base]["manifest_rel_path"] = manifest_rel_path else:
test_paths[url_base].manifest_rel_path = manifest_rel_path
def ensure_manifest_directories(logger, test_paths): for paths in test_paths.values():
manifest_path = (
paths["manifest_path"] if isinstance(paths, dict) else paths.manifest_path
)
manifest_dir = os.path.dirname(manifest_path) ifnot os.path.exists(manifest_dir):
logger.info("Creating directory %s" % manifest_dir) # Even though we just checked the path doesn't exist, there's a chance # of race condition with another process or thread having created it in # between. This happens during tests. try:
os.makedirs(manifest_dir) except OSError as e: if e.errno != errno.EEXIST: raise elifnot os.path.isdir(manifest_dir): raise IOError("Manifest directory is a file")
def generate_config(logger, repo_root, wpt_dir, dest_path, force_rewrite=False): """Generate the local wptrunner.ini file to use locally""" ifnot os.path.exists(dest_path): # Even though we just checked the path doesn't exist, there's a chance # of race condition with another process or thread having created it in # between. This happens during tests. try:
os.makedirs(dest_path) except OSError as e: if e.errno != errno.EEXIST: raise
if ( not force_rewrite and os.path.exists(dest_config_path) and os.stat(dest_config_path).st_mtime >= os.stat(src_config_path).st_mtime
):
logger.debug("Config is up to date, not regenerating") return dest_config_path
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.