Bug 1237179 - Add mach command to run firefox-ui-tests from the source directory. r=gps

This commit is contained in:
Henrik Skupin 2016-01-15 16:35:51 +01:00
parent 8d27a6ad68
commit 6c3729c1bc
3 changed files with 82 additions and 12 deletions

View File

@ -66,19 +66,14 @@ SEARCH_PATHS = [
'dom/bindings/parser',
'layout/tools/reftest',
'other-licenses/ply',
'xpcom/idl-parser',
'testing',
'testing/tools/autotry',
'testing/taskcluster',
'testing/xpcshell',
'testing/web-platform',
'testing/web-platform/harness',
'testing/web-platform/tests/tools/wptserve',
'testing/firefox-ui/harness',
'testing/firefox-ui/tests',
'testing/luciddream',
'testing/marionette/client',
'testing/marionette/client/marionette/runner/mixins/browsermob-proxy-py',
'testing/marionette/transport',
'testing/marionette/driver',
'testing/luciddream',
'testing/mozbase/mozcrash',
'testing/mozbase/mozdebug',
'testing/mozbase/mozdevice',
@ -97,6 +92,13 @@ SEARCH_PATHS = [
'testing/mozbase/moztest',
'testing/mozbase/mozversion',
'testing/mozbase/manifestparser',
'testing/puppeteer/firefox',
'testing/taskcluster',
'testing/tools/autotry',
'testing/web-platform',
'testing/web-platform/harness',
'testing/web-platform/tests/tools/wptserve',
'testing/xpcshell',
'xpcom/idl-parser',
]
@ -115,14 +117,14 @@ MACH_MODULES = [
'python/mozbuild/mozbuild/compilation/codecomplete.py',
'python/mozbuild/mozbuild/frontend/mach_commands.py',
'services/common/tests/mach_commands.py',
'testing/firefox-ui/mach_commands.py',
'testing/luciddream/mach_commands.py',
'testing/mach_commands.py',
'testing/taskcluster/mach_commands.py',
'testing/marionette/mach_commands.py',
'testing/mochitest/mach_commands.py',
'testing/mozharness/mach_commands.py',
'testing/xpcshell/mach_commands.py',
'testing/talos/mach_commands.py',
'testing/taskcluster/mach_commands.py',
'testing/web-platform/mach_commands.py',
'testing/xpcshell/mach_commands.py',
'tools/docs/mach_commands.py',

View File

@ -0,0 +1,68 @@
# 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 absolute_import, unicode_literals
import os
import sys
from mozbuild.base import (
MachCommandBase,
MachCommandConditions as conditions,
)
from mach.decorators import (
CommandProvider,
Command,
)
def setup_argument_parser():
from firefox_ui_harness.arguments.base import FirefoxUIArguments
return FirefoxUIArguments()
def run_firefox_ui_test(tests, testtype=None,
binary=None, topsrcdir=None, **kwargs):
from mozlog.structured import commandline
from firefox_ui_harness import cli_functional
from firefox_ui_harness.arguments import FirefoxUIArguments
parser = FirefoxUIArguments()
commandline.add_logging_group(parser)
args = parser.parse_args()
if not tests:
tests = [os.path.join(topsrcdir,
'testing/firefox-ui/tests/firefox_ui_tests/manifest.ini')]
args.tests = tests
args.binary = binary
path, exe = os.path.split(args.binary)
for k, v in kwargs.iteritems():
setattr(args, k, v)
parser.verify_usage(args)
args.logger = commandline.setup_logging("Firefox UI - Functional Tests",
args,
{"mach": sys.stdout})
failed = cli_functional.mn_cli(cli_functional.FirefoxUITestRunner, args=args)
if failed > 0:
return 1
else:
return 0
@CommandProvider
class MachCommands(MachCommandBase):
@Command('firefox-ui-test', category='testing',
description='Run Firefox UI functional tests.',
conditions=[conditions.is_firefox],
parser=setup_argument_parser,
)
def run_firefox_ui_test(self, tests, **kwargs):
kwargs['binary'] = self.get_binary_path('app')
return run_firefox_ui_test(tests, topsrcdir=self.topsrcdir, **kwargs)

View File

@ -77,7 +77,7 @@ class MarionetteHarness(object):
def cli(runner_class=MarionetteTestRunner, parser_class=MarionetteArguments,
harness_class=MarionetteHarness):
harness_class=MarionetteHarness, args=None):
"""
Call the harness to parse args and run tests.
@ -88,7 +88,7 @@ def cli(runner_class=MarionetteTestRunner, parser_class=MarionetteArguments,
"""
logger = mozlog.commandline.setup_logging('Marionette test runner', {})
try:
failed = harness_class(runner_class, parser_class).run()
failed = harness_class(runner_class, parser_class, args=args).run()
if failed > 0:
sys.exit(10)
except Exception: