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/.
8 from functools
import partial
10 from mach
.decorators
import Command
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")
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
53 parser
= BaseMarionetteArguments()
60 description
="Run a Marionette test (Check UI or the internal JavaScript "
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
)