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/.
9 from argparse
import ArgumentParser
12 'common', # Harnesses without a specific package will look here.
27 PACKAGE_SPECIFIED_HARNESSES
= [
39 # These packages are not present for every build configuration.
46 parser
= ArgumentParser(
47 description
="Generate a test_packages.json file to tell automation which harnesses "
48 "require which test packages.")
49 parser
.add_argument("--common", required
=True,
50 action
="store", dest
="tests_common",
51 help="Name of the \"common\" archive, a package to be used by all "
53 parser
.add_argument("--jsshell", required
=True,
54 action
="store", dest
="jsshell",
55 help="Name of the jsshell zip.")
56 for harness
in PACKAGE_SPECIFIED_HARNESSES
:
57 parser
.add_argument("--%s" % harness
, required
=True,
58 action
="store", dest
=harness
,
59 help="Name of the %s zip." % harness
)
60 for harness
in OPTIONAL_PACKAGES
:
61 parser
.add_argument("--%s" % harness
, required
=False,
62 action
="store", dest
=harness
,
63 help="Name of the %s zip." % harness
)
64 parser
.add_argument("--dest-file", required
=True,
65 action
="store", dest
="destfile",
66 help="Path to the output file to be written.")
67 return parser
.parse_args()
70 def generate_package_data(args
):
71 # Generate a dictionary mapping test harness names (exactly as they're known to
72 # mozharness and testsuite-targets.mk, ideally) to the set of archive names that
73 # harness depends on to run.
74 # mozharness will use this file to determine what test zips to download,
75 # which will be an optimization once parts of the main zip are split to harness
77 tests_common
= args
.tests_common
78 jsshell
= args
.jsshell
80 harness_requirements
= dict([(k
, [tests_common
]) for k
in ALL_HARNESSES
])
81 harness_requirements
['jittest'].append(jsshell
)
82 for harness
in PACKAGE_SPECIFIED_HARNESSES
+ OPTIONAL_PACKAGES
:
83 pkg_name
= getattr(args
, harness
, None)
86 harness_requirements
[harness
].append(pkg_name
)
87 return harness_requirements
90 if __name__
== '__main__':
92 packages_data
= generate_package_data(args
)
93 with
open(args
.destfile
, 'w') as of
:
94 json
.dump(packages_data
, of
, indent
=4)