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 from __future__
import absolute_import
11 from functools
import partial
13 from mach
.decorators
import (
21 def run_marionette(context
, **kwargs
):
22 from marionette
.runtests
import (
26 from mozlog
.structured
import commandline
28 args
= argparse
.Namespace(**kwargs
)
29 args
.binary
= args
.binary
or context
.firefox_bin
31 test_root
= os
.path
.join(context
.package_root
, 'marionette', 'tests')
33 args
.tests
= [os
.path
.join(test_root
, 'testing', 'marionette', 'harness',
34 'marionette_harness', 'tests', 'unit-tests.ini')]
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("Marionette Unit Tests",
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 parser
= BaseMarionetteArguments()
57 class MachCommands(object):
59 def __init__(self
, context
):
60 self
.context
= context
63 'marionette-test', category
='testing',
64 description
='Run a Marionette test (Check UI or the internal JavaScript '
66 parser
=setup_marionette_argument_parser
)
67 def run_marionette_test(self
, **kwargs
):
68 self
.context
.activate_mozharness_venv()
69 return run_marionette(self
.context
, **kwargs
)