gecko-dev/testing/firefox-ui/mach_commands.py

121 строка
3.9 KiB
Python
Исходник Обычный вид История

# 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 (
Command,
CommandProvider,
)
def setup_argument_parser_functional():
from firefox_ui_harness.arguments.base import FirefoxUIArguments
from mozlog.structured import commandline
parser = FirefoxUIArguments()
commandline.add_logging_group(parser)
return parser
def setup_argument_parser_update():
from firefox_ui_harness.arguments.update import UpdateArguments
from mozlog.structured import commandline
parser = UpdateArguments()
commandline.add_logging_group(parser)
return parser
def run_firefox_ui_test(testtype=None, topsrcdir=None, **kwargs):
from mozlog.structured import commandline
from argparse import Namespace
import firefox_ui_harness
if testtype == 'functional':
parser = setup_argument_parser_functional()
else:
parser = setup_argument_parser_update()
test_types = {
'functional': {
'default_tests': [
os.path.join('puppeteer', 'manifest.ini'),
os.path.join('functional', 'manifest.ini'),
],
'cli_module': firefox_ui_harness.cli_functional,
},
'update': {
'default_tests': [
os.path.join('update', 'manifest.ini'),
],
'cli_module': firefox_ui_harness.cli_update,
}
}
Bug 1239988 - Move resources for firefox-ui-tests out of tests folder. r=maja_zf MozReview-Commit-ID: KtUiswz9gna The resources folder should actually not be part of the tests folder. It contains test data for all tests and once tests are moved to other places the tests folder will not exist anymore. --HG-- rename : testing/firefox-ui/tests/resources/cookies/cookie_single.html => testing/firefox-ui/resources/cookies/cookie_single.html rename : testing/firefox-ui/tests/resources/images/firefox_favicon.ico => testing/firefox-ui/resources/images/firefox_favicon.ico rename : testing/firefox-ui/tests/resources/images/mozilla_favicon.ico => testing/firefox-ui/resources/images/mozilla_favicon.ico rename : testing/firefox-ui/tests/resources/images/mozilla_logo.jpg => testing/firefox-ui/resources/images/mozilla_logo.jpg rename : testing/firefox-ui/tests/resources/layout/mozilla.html => testing/firefox-ui/resources/layout/mozilla.html rename : testing/firefox-ui/tests/resources/layout/mozilla_community.html => testing/firefox-ui/resources/layout/mozilla_community.html rename : testing/firefox-ui/tests/resources/layout/mozilla_contribute.html => testing/firefox-ui/resources/layout/mozilla_contribute.html rename : testing/firefox-ui/tests/resources/layout/mozilla_governance.html => testing/firefox-ui/resources/layout/mozilla_governance.html rename : testing/firefox-ui/tests/resources/layout/mozilla_grants.html => testing/firefox-ui/resources/layout/mozilla_grants.html rename : testing/firefox-ui/tests/resources/layout/mozilla_mission.html => testing/firefox-ui/resources/layout/mozilla_mission.html rename : testing/firefox-ui/tests/resources/layout/mozilla_organizations.html => testing/firefox-ui/resources/layout/mozilla_organizations.html rename : testing/firefox-ui/tests/resources/layout/mozilla_projects.html => testing/firefox-ui/resources/layout/mozilla_projects.html rename : testing/firefox-ui/tests/resources/private_browsing/about.html => testing/firefox-ui/resources/private_browsing/about.html rename : testing/firefox-ui/tests/resources/security/enable_privilege.html => testing/firefox-ui/resources/security/enable_privilege.html extra : rebase_source : 722311a780f6e36ef4f2e08b82117fdf78625620
2016-03-10 16:21:54 +03:00
fxui_dir = os.path.join(topsrcdir, 'testing', 'firefox-ui')
# Set the resources path which is used to serve test data via wptserve
if not kwargs['server_root']:
Bug 1239988 - Move resources for firefox-ui-tests out of tests folder. r=maja_zf MozReview-Commit-ID: KtUiswz9gna The resources folder should actually not be part of the tests folder. It contains test data for all tests and once tests are moved to other places the tests folder will not exist anymore. --HG-- rename : testing/firefox-ui/tests/resources/cookies/cookie_single.html => testing/firefox-ui/resources/cookies/cookie_single.html rename : testing/firefox-ui/tests/resources/images/firefox_favicon.ico => testing/firefox-ui/resources/images/firefox_favicon.ico rename : testing/firefox-ui/tests/resources/images/mozilla_favicon.ico => testing/firefox-ui/resources/images/mozilla_favicon.ico rename : testing/firefox-ui/tests/resources/images/mozilla_logo.jpg => testing/firefox-ui/resources/images/mozilla_logo.jpg rename : testing/firefox-ui/tests/resources/layout/mozilla.html => testing/firefox-ui/resources/layout/mozilla.html rename : testing/firefox-ui/tests/resources/layout/mozilla_community.html => testing/firefox-ui/resources/layout/mozilla_community.html rename : testing/firefox-ui/tests/resources/layout/mozilla_contribute.html => testing/firefox-ui/resources/layout/mozilla_contribute.html rename : testing/firefox-ui/tests/resources/layout/mozilla_governance.html => testing/firefox-ui/resources/layout/mozilla_governance.html rename : testing/firefox-ui/tests/resources/layout/mozilla_grants.html => testing/firefox-ui/resources/layout/mozilla_grants.html rename : testing/firefox-ui/tests/resources/layout/mozilla_mission.html => testing/firefox-ui/resources/layout/mozilla_mission.html rename : testing/firefox-ui/tests/resources/layout/mozilla_organizations.html => testing/firefox-ui/resources/layout/mozilla_organizations.html rename : testing/firefox-ui/tests/resources/layout/mozilla_projects.html => testing/firefox-ui/resources/layout/mozilla_projects.html rename : testing/firefox-ui/tests/resources/private_browsing/about.html => testing/firefox-ui/resources/private_browsing/about.html rename : testing/firefox-ui/tests/resources/security/enable_privilege.html => testing/firefox-ui/resources/security/enable_privilege.html extra : rebase_source : 722311a780f6e36ef4f2e08b82117fdf78625620
2016-03-10 16:21:54 +03:00
kwargs['server_root'] = os.path.join(fxui_dir, 'resources')
# If called via "mach test" a dictionary of tests is passed in
if 'test_objects' in kwargs:
tests = []
for obj in kwargs['test_objects']:
tests.append(obj['file_relpath'])
kwargs['tests'] = tests
elif not kwargs.get('tests'):
# If no tests have been selected, set default ones
kwargs['tests'] = [os.path.join(fxui_dir, 'tests', test)
for test in test_types[testtype]['default_tests']]
kwargs['logger'] = commandline.setup_logging('Firefox UI - {} Tests'.format(testtype),
{"mach": sys.stdout})
args = Namespace()
for k, v in kwargs.iteritems():
setattr(args, k, v)
parser.verify_usage(args)
failed = test_types[testtype]['cli_module'].cli(args=vars(args))
if failed > 0:
return 1
else:
return 0
@CommandProvider
class MachCommands(MachCommandBase):
"""Mach command provider for Firefox ui tests."""
@Command('firefox-ui-functional', category='testing',
conditions=[conditions.is_firefox],
description='Run the functional test suite of Firefox UI tests.',
parser=setup_argument_parser_functional,
)
def run_firefox_ui_functional(self, **kwargs):
kwargs['binary'] = kwargs['binary'] or self.get_binary_path('app')
return run_firefox_ui_test(testtype='functional',
topsrcdir=self.topsrcdir, **kwargs)
@Command('firefox-ui-update', category='testing',
conditions=[conditions.is_firefox],
description='Run the update test suite of Firefox UI tests.',
parser=setup_argument_parser_update,
)
def run_firefox_ui_update(self, **kwargs):
kwargs['binary'] = kwargs['binary'] or self.get_binary_path('app')
return run_firefox_ui_test(testtype='update',
topsrcdir=self.topsrcdir, **kwargs)