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
30 args
.e10s
= context
.mozharness_config
.get('e10s', args
.e10s
)
32 test_root
= os
.path
.join(context
.package_root
, 'marionette', 'tests')
34 args
.tests
= [os
.path
.join(test_root
, 'testing', 'marionette', 'harness',
35 'marionette_harness', 'tests', 'unit-tests.ini')]
37 normalize
= partial(context
.normalize_test_path
, test_root
)
38 args
.tests
= map(normalize
, args
.tests
)
40 commandline
.add_logging_group(parser
)
41 parser
.verify_usage(args
)
43 args
.logger
= commandline
.setup_logging("Marionette Unit Tests",
46 status
= MarionetteHarness(MarionetteTestRunner
, args
=vars(args
)).run()
47 return 1 if status
else 0
50 def setup_marionette_argument_parser():
51 from marionette
.runner
.base
import BaseMarionetteArguments
53 parser
= BaseMarionetteArguments()
58 class MachCommands(object):
60 def __init__(self
, context
):
61 self
.context
= context
64 'marionette-test', category
='testing',
65 description
='Run a Marionette test (Check UI or the internal JavaScript '
67 parser
=setup_marionette_argument_parser
)
68 def run_marionette_test(self
, **kwargs
):
69 self
.context
.activate_mozharness_venv()
70 return run_marionette(self
.context
, **kwargs
)