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
, unicode_literals
9 from argparse
import Namespace
10 from functools
import partial
14 from xpcshellcommandline
import parser_desktop
16 from mach
.decorators
import (
21 def run_xpcshell(context
, **kwargs
):
22 args
= Namespace(**kwargs
)
23 args
.appPath
= args
.appPath
or os
.path
.dirname(context
.firefox_bin
)
24 args
.utility_path
= context
.bin_dir
25 args
.testingModulesDir
= context
.modules_dir
28 args
.xpcshell
= os
.path
.join(args
.appPath
, "xpcshell")
30 if not args
.pluginsPath
:
31 for path
in context
.ancestors(args
.appPath
, depth
=2):
32 test
= os
.path
.join(path
, "plugins")
33 if os
.path
.isdir(test
):
34 args
.pluginsPath
= test
37 log
= mozlog
.commandline
.setup_logging(
38 "XPCShellTests", args
, {"mach": sys
.stdout
}, {"verbose": True}
42 test_root
= os
.path
.join(context
.package_root
, "xpcshell", "tests")
43 normalize
= partial(context
.normalize_test_path
, test_root
)
44 # pylint --py3k: W1636
45 args
.testPaths
= list(map(normalize
, args
.testPaths
))
47 import runxpcshelltests
49 xpcshell
= runxpcshelltests
.XPCShellTests(log
=log
)
50 return xpcshell
.runTests(**vars(args
))
56 description
="Run the xpcshell harness.",
57 parser
=parser_desktop
,
59 def xpcshell(command_context
, **kwargs
):
60 command_context
._mach
_context
.activate_mozharness_venv()
61 return run_xpcshell(command_context
._mach
_context
, **kwargs
)