tor-browser

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

gen_test_packages_manifest.py (3616B)


      1 #!/usr/bin/python
      2 #
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 import json
      8 from argparse import ArgumentParser
      9 
     10 ALL_HARNESSES = [
     11    "common",  # Harnesses without a specific package will look here.
     12    "condprof",
     13    "mochitest",
     14    "reftest",
     15    "xpcshell",
     16    "cppunittest",
     17    "jittest",
     18    "mozbase",
     19    "web-platform",
     20    "talos",
     21    "raptor",
     22    "awsy",
     23    "gtest",
     24    "updater-dep",
     25    "jsreftest",
     26    "perftests",
     27    "fuzztest",
     28    "trainhop",
     29 ]
     30 
     31 PACKAGE_SPECIFIED_HARNESSES = [
     32    "condprof",
     33    "cppunittest",
     34    "mochitest",
     35    "reftest",
     36    "xpcshell",
     37    "web-platform",
     38    "talos",
     39    "raptor",
     40    "awsy",
     41    "updater-dep",
     42    "jittest",
     43    "jsreftest",
     44    "perftests",
     45    "fuzztest",
     46    "trainhop",
     47 ]
     48 
     49 # These packages are not present for every build configuration.
     50 OPTIONAL_PACKAGES = [
     51    "gtest",
     52 ]
     53 
     54 
     55 def parse_args():
     56    parser = ArgumentParser(
     57        description="Generate a test_packages.json file to tell automation which harnesses "
     58        "require which test packages."
     59    )
     60    parser.add_argument(
     61        "--common",
     62        required=True,
     63        action="store",
     64        dest="tests_common",
     65        help='Name of the "common" archive, a package to be used by all harnesses.',
     66    )
     67    parser.add_argument(
     68        "--jsshell",
     69        required=True,
     70        action="store",
     71        dest="jsshell",
     72        help="Name of the jsshell zip.",
     73    )
     74    for harness in PACKAGE_SPECIFIED_HARNESSES:
     75        parser.add_argument(
     76            "--%s" % harness,
     77            required=True,
     78            action="store",
     79            dest=harness,
     80            help="Name of the %s zip." % harness,
     81        )
     82    for harness in OPTIONAL_PACKAGES:
     83        parser.add_argument(
     84            "--%s" % harness,
     85            required=False,
     86            action="store",
     87            dest=harness,
     88            help="Name of the %s zip." % harness,
     89        )
     90    parser.add_argument(
     91        "--dest-file",
     92        required=True,
     93        action="store",
     94        dest="destfile",
     95        help="Path to the output file to be written.",
     96    )
     97    return parser.parse_args()
     98 
     99 
    100 def generate_package_data(args):
    101    # Generate a dictionary mapping test harness names (exactly as they're known to
    102    # mozharness and testsuite-targets.mk, ideally) to the set of archive names that
    103    # harness depends on to run.
    104    # mozharness will use this file to determine what test zips to download,
    105    # which will be an optimization once parts of the main zip are split to harness
    106    # specific zips.
    107    tests_common = args.tests_common
    108    jsshell = args.jsshell
    109 
    110    harness_requirements = dict([(k, [tests_common]) for k in ALL_HARNESSES])
    111    harness_requirements["jittest"].append(jsshell)
    112    harness_requirements["jsreftest"].append(args.reftest)
    113    harness_requirements["common"].append("target.condprof.tests.tar.zst")
    114    for harness in PACKAGE_SPECIFIED_HARNESSES + OPTIONAL_PACKAGES:
    115        pkg_name = getattr(args, harness, None)
    116        if pkg_name is None:
    117            continue
    118        harness_requirements[harness].append(pkg_name)
    119        harness_requirements[harness].append("target.condprof.tests.tar.zst")
    120        harness_requirements[harness].append("target.trainhop.tests.tar.zst")
    121    return harness_requirements
    122 
    123 
    124 if __name__ == "__main__":
    125    args = parse_args()
    126    packages_data = generate_package_data(args)
    127    with open(args.destfile, "w") as of:
    128        json.dump(packages_data, of, indent=4)