tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mach_test_package_commands.py (1510B)


      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/.
      4 
      5 import os
      6 import sys
      7 from argparse import Namespace
      8 from functools import partial
      9 
     10 import mozlog
     11 from mach.decorators import Command
     12 from xpcshellcommandline import parser_desktop
     13 
     14 
     15 def run_xpcshell(context, **kwargs):
     16    args = Namespace(**kwargs)
     17    args.appPath = args.appPath or os.path.dirname(context.firefox_bin)
     18    args.utility_path = context.bin_dir
     19    args.testingModulesDir = context.modules_dir
     20 
     21    if not args.xpcshell:
     22        args.xpcshell = os.path.join(args.appPath, "xpcshell")
     23 
     24    log = mozlog.commandline.setup_logging(
     25        "XPCShellTests", args, {"mach": sys.stdout}, {"verbose": True}
     26    )
     27 
     28    if args.testPaths:
     29        test_root = os.path.join(context.package_root, "xpcshell", "tests")
     30        normalize = partial(context.normalize_test_path, test_root)
     31        # pylint --py3k: W1636
     32        args.testPaths = list(map(normalize, args.testPaths))
     33 
     34    import runxpcshelltests
     35 
     36    xpcshell = runxpcshelltests.XPCShellTests(log=log)
     37    return xpcshell.runTests(**vars(args))
     38 
     39 
     40 @Command(
     41    "xpcshell-test",
     42    category="testing",
     43    description="Run the xpcshell harness.",
     44    parser=parser_desktop,
     45 )
     46 def xpcshell(command_context, **kwargs):
     47    command_context._mach_context.activate_mozharness_venv()
     48    return run_xpcshell(command_context._mach_context, **kwargs)