Backed out changeset 0a133d5fd155 (bug 1864534) for causing screenshot related failur...
[gecko.git] / testing / marionette / mach_test_package_commands.py
blob0bb3df8b89cd77ad2db0481fbf72a32f1efa593b
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/.
5 import argparse
6 import os
7 import sys
8 from functools import partial
10 from mach.decorators import Command
12 parser = None
15 def run_marionette(context, **kwargs):
16 from marionette.runtests import MarionetteHarness, MarionetteTestRunner
17 from mozlog.structured import commandline
19 args = argparse.Namespace(**kwargs)
20 args.binary = args.binary or context.firefox_bin
22 test_root = os.path.join(context.package_root, "marionette", "tests")
23 if not args.tests:
24 args.tests = [
25 os.path.join(
26 test_root,
27 "testing",
28 "marionette",
29 "harness",
30 "marionette_harness",
31 "tests",
32 "unit-tests.toml",
36 normalize = partial(context.normalize_test_path, test_root)
37 args.tests = list(map(normalize, args.tests))
39 commandline.add_logging_group(parser)
40 parser.verify_usage(args)
42 args.logger = commandline.setup_logging(
43 "Marionette Unit Tests", args, {"mach": sys.stdout}
45 status = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run()
46 return 1 if status else 0
49 def setup_marionette_argument_parser():
50 from marionette.runner.base import BaseMarionetteArguments
52 global parser
53 parser = BaseMarionetteArguments()
54 return parser
57 @Command(
58 "marionette-test",
59 category="testing",
60 description="Run a Marionette test (Check UI or the internal JavaScript "
61 "using marionette).",
62 parser=setup_marionette_argument_parser,
64 def run_marionette_test(command_context, **kwargs):
65 command_context.context.activate_mozharness_venv()
66 return run_marionette(command_context.context, **kwargs)