gen_test_packages_manifest.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. import json
  7. from argparse import ArgumentParser
  8. ALL_HARNESSES = [
  9. 'common', # Harnesses without a specific package will look here.
  10. 'mochitest',
  11. 'reftest',
  12. 'xpcshell',
  13. 'cppunittest',
  14. 'jittest',
  15. 'mozbase',
  16. 'web-platform',
  17. 'talos',
  18. 'gtest',
  19. ]
  20. PACKAGE_SPECIFIED_HARNESSES = [
  21. 'cppunittest',
  22. 'mochitest',
  23. 'reftest',
  24. 'xpcshell',
  25. 'web-platform',
  26. 'talos',
  27. ]
  28. # These packages are not present for every build configuration.
  29. OPTIONAL_PACKAGES = [
  30. 'gtest',
  31. ]
  32. def parse_args():
  33. parser = ArgumentParser(description='Generate a test_packages.json file to tell automation which harnesses require which test packages.')
  34. parser.add_argument("--common", required=True,
  35. action="store", dest="tests_common",
  36. help="Name of the \"common\" archive, a package to be used by all harnesses.")
  37. parser.add_argument("--jsshell", required=True,
  38. action="store", dest="jsshell",
  39. help="Name of the jsshell zip.")
  40. for harness in PACKAGE_SPECIFIED_HARNESSES:
  41. parser.add_argument("--%s" % harness, required=True,
  42. action="store", dest=harness,
  43. help="Name of the %s zip." % harness)
  44. for harness in OPTIONAL_PACKAGES:
  45. parser.add_argument("--%s" % harness, required=False,
  46. action="store", dest=harness,
  47. help="Name of the %s zip." % harness)
  48. parser.add_argument("--dest-file", required=True,
  49. action="store", dest="destfile",
  50. help="Path to the output file to be written.")
  51. return parser.parse_args()
  52. def generate_package_data(args):
  53. # Generate a dictionary mapping test harness names (exactly as they're known to
  54. # mozharness and testsuite-targets.mk, ideally) to the set of archive names that
  55. # harness depends on to run.
  56. # mozharness will use this file to determine what test zips to download,
  57. # which will be an optimization once parts of the main zip are split to harness
  58. # specific zips.
  59. tests_common = args.tests_common
  60. jsshell = args.jsshell
  61. harness_requirements = dict([(k, [tests_common]) for k in ALL_HARNESSES])
  62. harness_requirements['jittest'].append(jsshell)
  63. for harness in PACKAGE_SPECIFIED_HARNESSES + OPTIONAL_PACKAGES:
  64. pkg_name = getattr(args, harness, None)
  65. if pkg_name is None:
  66. continue
  67. harness_requirements[harness].append(pkg_name)
  68. return harness_requirements
  69. if __name__ == '__main__':
  70. args = parse_args()
  71. packages_data = generate_package_data(args)
  72. with open(args.destfile, 'w') as of:
  73. json.dump(packages_data, of, indent=4)