mach_test_package_commands.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. from __future__ import unicode_literals
  5. import os
  6. from argparse import Namespace
  7. from functools import partial
  8. from mach.decorators import (
  9. CommandProvider,
  10. Command,
  11. )
  12. here = os.path.abspath(os.path.dirname(__file__))
  13. parser = None
  14. def run_mochitest(context, **kwargs):
  15. args = Namespace(**kwargs)
  16. args.e10s = context.mozharness_config.get('e10s', args.e10s)
  17. args.certPath = context.certs_dir
  18. if args.test_paths:
  19. test_root = os.path.join(context.package_root, 'mochitest', 'tests')
  20. normalize = partial(context.normalize_test_path, test_root)
  21. args.test_paths = map(normalize, args.test_paths)
  22. import mozinfo
  23. return run_mochitest_desktop(context, args)
  24. def run_mochitest_desktop(context, args):
  25. args.app = args.app or context.firefox_bin
  26. args.utilityPath = context.bin_dir
  27. args.extraProfileFiles.append(os.path.join(context.bin_dir, 'plugins'))
  28. from runtests import run_test_harness
  29. return run_test_harness(parser, args)
  30. def setup_argument_parser():
  31. import mozinfo
  32. mozinfo.find_and_update_from_json(here)
  33. app = 'generic'
  34. from mochitest_options import MochitestArgumentParser
  35. global parser
  36. parser = MochitestArgumentParser(app=app)
  37. return parser
  38. @CommandProvider
  39. class MochitestCommands(object):
  40. def __init__(self, context):
  41. self.context = context
  42. @Command('mochitest', category='testing',
  43. description='Run the mochitest harness.',
  44. parser=setup_argument_parser)
  45. def mochitest(self, **kwargs):
  46. return run_mochitest(self.context, **kwargs)