| 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 |
] |
| 29 |
|
| 30 |
PACKAGE_SPECIFIED_HARNESSES = [ |
| 31 |
"condprof", |
| 32 |
"cppunittest", |
| 33 |
"mochitest", |
| 34 |
"reftest", |
| 35 |
"xpcshell", |
| 36 |
"web-platform", |
| 37 |
"talos", |
| 38 |
"raptor", |
| 39 |
"awsy", |
| 40 |
"updater-dep", |
| 41 |
"jittest", |
| 42 |
"jsreftest", |
| 43 |
"perftests", |
| 44 |
"fuzztest", |
| 45 |
] |
| 46 |
|
| 47 |
# These packages are not present for every build configuration. |
| 48 |
OPTIONAL_PACKAGES = [ |
| 49 |
"gtest", |
| 50 |
] |
| 51 |
|
| 52 |
|
| 53 |
def parse_args(): |
| 54 |
parser = ArgumentParser( |
| 55 |
description="Generate a test_packages.json file to tell automation which harnesses " |
| 56 |
"require which test packages." |
| 57 |
) |
| 58 |
parser.add_argument( |
| 59 |
"--common", |
| 60 |
required=True, |
| 61 |
action="store", |
| 62 |
dest="tests_common", |
| 63 |
help='Name of the "common" archive, a package to be used by all ' "harnesses.", |
| 64 |
) |
| 65 |
parser.add_argument( |
| 66 |
"--jsshell", |
| 67 |
required=True, |
| 68 |
action="store", |
| 69 |
dest="jsshell", |
| 70 |
help="Name of the jsshell zip.", |
| 71 |
) |
| 72 |
for harness in PACKAGE_SPECIFIED_HARNESSES: |
| 73 |
parser.add_argument( |
| 74 |
"--%s" % harness, |
| 75 |
required=True, |
| 76 |
action="store", |
| 77 |
dest=harness, |
| 78 |
help="Name of the %s zip." % harness, |
| 79 |
) |
| 80 |
for harness in OPTIONAL_PACKAGES: |
| 81 |
parser.add_argument( |
| 82 |
"--%s" % harness, |
| 83 |
required=False, |
| 84 |
action="store", |
| 85 |
dest=harness, |
| 86 |
help="Name of the %s zip." % harness, |
| 87 |
) |
| 88 |
parser.add_argument( |
| 89 |
"--dest-file", |
| 90 |
required=True, |
| 91 |
action="store", |
| 92 |
dest="destfile", |
| 93 |
help="Path to the output file to be written.", |
| 94 |
) |
| 95 |
return parser.parse_args() |
| 96 |
|
| 97 |
|
| 98 |
def generate_package_data(args): |
| 99 |
# Generate a dictionary mapping test harness names (exactly as they're known to |
| 100 |
# mozharness and testsuite-targets.mk, ideally) to the set of archive names that |
| 101 |
# harness depends on to run. |
| 102 |
# mozharness will use this file to determine what test zips to download, |
| 103 |
# which will be an optimization once parts of the main zip are split to harness |
| 104 |
# specific zips. |
| 105 |
tests_common = args.tests_common |
| 106 |
jsshell = args.jsshell |
| 107 |
|
| 108 |
harness_requirements = dict([(k, [tests_common]) for k in ALL_HARNESSES]) |
| 109 |
harness_requirements["jittest"].append(jsshell) |
| 110 |
harness_requirements["jsreftest"].append(args.reftest) |
| 111 |
harness_requirements["common"].append("target.condprof.tests.tar.gz") |
| 112 |
for harness in PACKAGE_SPECIFIED_HARNESSES + OPTIONAL_PACKAGES: |
| 113 |
pkg_name = getattr(args, harness, None) |
| 114 |
if pkg_name is None: |
| 115 |
continue |
| 116 |
harness_requirements[harness].append(pkg_name) |
| 117 |
harness_requirements[harness].append("target.condprof.tests.tar.gz") |
| 118 |
return harness_requirements |
| 119 |
|
| 120 |
|
| 121 |
if __name__ == "__main__": |
| 122 |
args = parse_args() |
| 123 |
packages_data = generate_package_data(args) |
| 124 |
with open(args.destfile, "w") as of: |
| 125 |
json.dump(packages_data, of, indent=4) |