2015-05-26 17:12:51 +03:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import os
|
2016-07-20 18:13:30 +03:00
|
|
|
from argparse import Namespace
|
|
|
|
from functools import partial
|
2015-05-26 17:12:51 +03:00
|
|
|
|
|
|
|
from mach.decorators import (
|
|
|
|
CommandProvider,
|
|
|
|
Command,
|
|
|
|
)
|
|
|
|
|
2016-07-20 18:13:30 +03:00
|
|
|
parser = None
|
|
|
|
|
2015-05-26 17:12:51 +03:00
|
|
|
|
|
|
|
def run_mochitest(context, **kwargs):
|
|
|
|
args = Namespace(**kwargs)
|
|
|
|
args.certPath = context.certs_dir
|
|
|
|
args.utilityPath = context.bin_dir
|
|
|
|
args.extraProfileFiles.append(os.path.join(context.bin_dir, 'plugins'))
|
|
|
|
|
2016-07-20 18:13:30 +03:00
|
|
|
if not args.app:
|
|
|
|
args.app = context.find_firefox()
|
|
|
|
|
|
|
|
if args.test_paths:
|
|
|
|
test_root = os.path.join(context.package_root, 'mochitest', 'tests')
|
|
|
|
normalize = partial(context.normalize_test_path, test_root)
|
|
|
|
args.test_paths = map(normalize, args.test_paths)
|
|
|
|
|
2015-05-26 17:12:51 +03:00
|
|
|
from runtests import run_test_harness
|
2016-07-20 18:13:30 +03:00
|
|
|
return run_test_harness(parser, args)
|
2015-05-26 17:12:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
def setup_argument_parser():
|
|
|
|
from mochitest_options import MochitestArgumentParser
|
2016-07-20 18:13:30 +03:00
|
|
|
global parser
|
|
|
|
parser = MochitestArgumentParser(app='generic')
|
|
|
|
return parser
|
2015-05-26 17:12:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
@CommandProvider
|
|
|
|
class MochitestCommands(object):
|
|
|
|
|
|
|
|
def __init__(self, context):
|
|
|
|
self.context = context
|
|
|
|
|
|
|
|
@Command('mochitest', category='testing',
|
|
|
|
description='Run the mochitest harness.',
|
|
|
|
parser=setup_argument_parser)
|
|
|
|
def mochitest(self, **kwargs):
|
|
|
|
return run_mochitest(self.context, **kwargs)
|