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/.
|
|
|
|
|
2017-09-28 15:58:36 +03:00
|
|
|
from __future__ import unicode_literals
|
2015-05-26 17:12:51 +03:00
|
|
|
|
2016-07-28 18:04:42 +03:00
|
|
|
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-09-02 21:43:53 +03:00
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
2016-07-20 18:13:30 +03:00
|
|
|
parser = None
|
|
|
|
|
2015-05-26 17:12:51 +03:00
|
|
|
|
|
|
|
def run_mochitest(context, **kwargs):
|
2016-12-20 19:24:33 +03:00
|
|
|
from mochitest_options import ALL_FLAVORS
|
|
|
|
flavor = kwargs.get('flavor') or 'mochitest'
|
|
|
|
if flavor not in ALL_FLAVORS:
|
|
|
|
for fname, fobj in ALL_FLAVORS.iteritems():
|
|
|
|
if flavor in fobj['aliases']:
|
|
|
|
flavor = fname
|
|
|
|
break
|
|
|
|
fobj = ALL_FLAVORS[flavor]
|
|
|
|
kwargs.update(fobj.get('extra_args', {}))
|
|
|
|
|
2015-05-26 17:12:51 +03:00
|
|
|
args = Namespace(**kwargs)
|
2016-09-02 21:42:36 +03:00
|
|
|
args.e10s = context.mozharness_config.get('e10s', args.e10s)
|
2015-05-26 17:12:51 +03:00
|
|
|
args.certPath = context.certs_dir
|
2016-07-20 18:13:30 +03:00
|
|
|
|
|
|
|
if args.test_paths:
|
2016-12-20 19:24:33 +03:00
|
|
|
install_subdir = fobj.get('install_subdir', fobj['suite'])
|
|
|
|
test_root = os.path.join(context.package_root, 'mochitest', install_subdir)
|
2016-07-20 18:13:30 +03:00
|
|
|
normalize = partial(context.normalize_test_path, test_root)
|
|
|
|
args.test_paths = map(normalize, args.test_paths)
|
|
|
|
|
2016-09-02 21:43:53 +03:00
|
|
|
import mozinfo
|
2016-10-21 19:24:17 +03:00
|
|
|
if mozinfo.info.get('buildapp') == 'mobile/android':
|
2016-09-02 21:43:53 +03:00
|
|
|
return run_mochitest_android(context, args)
|
2016-09-02 21:35:14 +03:00
|
|
|
return run_mochitest_desktop(context, args)
|
|
|
|
|
|
|
|
|
|
|
|
def run_mochitest_desktop(context, args):
|
|
|
|
args.app = args.app or context.firefox_bin
|
|
|
|
args.utilityPath = context.bin_dir
|
|
|
|
args.extraProfileFiles.append(os.path.join(context.bin_dir, 'plugins'))
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2016-09-02 21:43:53 +03:00
|
|
|
def run_mochitest_android(context, args):
|
|
|
|
args.app = args.app or 'org.mozilla.fennec'
|
|
|
|
args.extraProfileFiles.append(os.path.join(context.package_root, 'mochitest', 'fonts'))
|
|
|
|
args.utilityPath = context.hostutils
|
|
|
|
args.xrePath = context.hostutils
|
|
|
|
|
|
|
|
config = context.mozharness_config
|
|
|
|
if config:
|
|
|
|
args.remoteWebServer = config['remote_webserver']
|
|
|
|
args.httpPort = config['emulator']['http_port']
|
|
|
|
args.sslPort = config['emulator']['ssl_port']
|
|
|
|
args.adbPath = config['exes']['adb'] % {'abs_work_dir': context.mozharness_workdir}
|
|
|
|
|
|
|
|
from runtestsremote import run_test_harness
|
|
|
|
return run_test_harness(parser, args)
|
|
|
|
|
|
|
|
|
2015-05-26 17:12:51 +03:00
|
|
|
def setup_argument_parser():
|
2016-09-02 21:43:53 +03:00
|
|
|
import mozinfo
|
2016-10-21 19:24:17 +03:00
|
|
|
mozinfo.find_and_update_from_json(here)
|
2016-09-02 21:43:53 +03:00
|
|
|
app = 'generic'
|
|
|
|
if mozinfo.info.get('buildapp') == 'mobile/android':
|
|
|
|
app = 'android'
|
|
|
|
|
2015-05-26 17:12:51 +03:00
|
|
|
from mochitest_options import MochitestArgumentParser
|
2016-07-20 18:13:30 +03:00
|
|
|
global parser
|
2016-09-02 21:43:53 +03:00
|
|
|
parser = MochitestArgumentParser(app=app)
|
2016-07-20 18:13:30 +03:00
|
|
|
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):
|
2017-01-31 19:53:36 +03:00
|
|
|
self.context.activate_mozharness_venv()
|
2015-05-26 17:12:51 +03:00
|
|
|
return run_mochitest(self.context, **kwargs)
|