Bug 799308 - Mach command for running Marionette, r=gps

This commit is contained in:
Gregory Szorc 2013-04-19 05:19:54 -07:00
Родитель 056b56c939
Коммит 201dcd21f9
3 изменённых файлов: 94 добавлений и 6 удалений

Просмотреть файл

@ -22,10 +22,17 @@ SEARCH_PATHS = [
'xpcom/idl-parser',
'testing',
'testing/xpcshell',
'testing/marionette/client',
'testing/marionette/client/marionette',
'testing/mozbase/mozcrash',
'testing/mozbase/mozlog',
'testing/mozbase/mozprocess',
'testing/mozbase/mozdevice',
'testing/mozbase/mozfile',
'testing/mozbase/mozhttpd',
'testing/mozbase/mozlog',
'testing/mozbase/moznetwork',
'testing/mozbase/mozprocess',
'testing/mozbase/mozprofile',
'testing/mozbase/mozrunner',
'testing/mozbase/mozinfo',
]
@ -38,6 +45,7 @@ MACH_MODULES = [
'python/mozbuild/mozbuild/config.py',
'python/mozbuild/mozbuild/mach_commands.py',
'python/mozbuild/mozbuild/frontend/mach_commands.py',
'testing/marionette/mach_commands.py',
'testing/mochitest/mach_commands.py',
'testing/xpcshell/mach_commands.py',
'tools/mach_commands.py',

Просмотреть файл

@ -637,9 +637,7 @@ class MarionetteTestOptions(OptionParser):
action='store',
help='absolute path to directory containing breakpad symbols, or the url of a zip file containing symbols')
def verify_usage(self):
options, tests = self.parse_args()
def verify_usage(self, options, tests):
if not tests:
print 'must specify one or more test files, manifests, or directories'
sys.exit(1)
@ -664,6 +662,8 @@ class MarionetteTestOptions(OptionParser):
raise ValueError('Invalid emulator resolution format. '
'Should be like "480x800".')
return (options, tests)
def startTestRunner(runner_class, options, tests):
runner = runner_class(**vars(options))
@ -672,8 +672,8 @@ def startTestRunner(runner_class, options, tests):
def cli(runner_class=MarionetteTestRunner, parser_class=MarionetteTestOptions):
parser = parser_class(usage='%prog [options] test_file_or_dir <test_file_or_dir> ...')
parser.verify_usage()
options, tests = parser.parse_args()
parser.verify_usage(options, tests)
runner = startTestRunner(runner_class, options, tests)
if runner.failed > 0:

Просмотреть файл

@ -0,0 +1,80 @@
# 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
from mozbuild.base import MachCommandBase
from mach.decorators import (
CommandArgument,
CommandProvider,
Command,
)
@CommandProvider
class MachCommands(MachCommandBase):
@Command('marionette-test', help='Run a Marionette test.')
@CommandArgument('--homedir', dest='b2g_path',
help='For B2G testing, the path to the B2G repo.')
@CommandArgument('--emulator', choices=['x86', 'arm'],
help='Run an emulator of the specified architecture.')
@CommandArgument('--address',
help='host:port of running Gecko instance to connect to.')
@CommandArgument('--type', dest='testtype',
help='Test type, usually one of: browser, b2g, b2g-qemu.')
@CommandArgument('tests', nargs='*', metavar='TESTS',
help='Path to test(s) to run.')
def run_marionette(self, tests, emulator=None, address=None, b2g_path=None,
testtype=None):
from marionette.runtests import (
MarionetteTestRunner,
MarionetteTestOptions,
startTestRunner
)
parser = MarionetteTestOptions()
options, args = parser.parse_args()
if not tests:
tests = ['testing/marionette/client/marionette/tests/unit-tests.ini']
options.type = testtype
if emulator:
if b2g_path:
options.homedir = b2g_path
if not testtype:
options.type = "b2g"
else:
if not testtype:
options.type = "browser"
try:
bin = self.get_binary_path('app')
options.bin = bin
except Exception as e:
print("It looks like your program isn't built.",
"You can run |mach build| to build it.")
print(e)
return 1
path, exe = os.path.split(options.bin)
if 'b2g' in exe:
options.app = 'b2gdesktop'
if not emulator:
if self.substs.get('ENABLE_MARIONETTE') != '1':
print("Marionette doesn't appear to be enabled; please "
"add ENABLE_MARIONETTE=1 to your mozconfig and "
"perform a clobber build.")
return 1
options.address = address
parser.verify_usage(options, tests)
runner = startTestRunner(MarionetteTestRunner, options, tests)
if runner.failed > 0:
return 1
return 0