From 2ea977168113a137c7ae342d46ce87c7865ff5a8 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Wed, 25 Nov 2015 13:10:03 +0100 Subject: [PATCH] Bug 1227570 - Remove support of the --installer command line option. r=maja_zf (cherry picked from commit 0121c2a7d4fd3cf914b3e031a6b69145e5fe9ace) --- .travis.yml | 22 +++++-------- .travis/download-and-install.py | 21 ++++++++++++ firefox_ui_harness/arguments/base.py | 16 +-------- firefox_ui_harness/arguments/update.py | 10 +++--- firefox_ui_harness/runners/base.py | 17 ++++++++++ firefox_ui_harness/runners/update.py | 27 +++------------- firefox_ui_harness/runtests.py | 45 -------------------------- 7 files changed, 57 insertions(+), 101 deletions(-) create mode 100644 .travis/download-and-install.py diff --git a/.travis.yml b/.travis.yml index 201bb940..b03c2536 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,26 +16,20 @@ env: - MOZ_BRANCH='mozilla-beta' - DISPLAY=$(if [[ $TRAVIS_OS_NAME = 'linux' ]]; then echo ':99'; fi) - MOZ_XVFB=$(if [[ $TRAVIS_OS_NAME = 'linux' ]]; then echo 1; fi) + matrix: - # Test with our internal pypi mirror / locale en-US + # Test with our internal pypi mirror / en-US only - LOCALE='en-US' PIP_FIND_LINKS=http://pypi.pub.build.mozilla.org/pub PIP_NO_INDEX=1 - PIP_STRICT_VERSIONS=--strict - # ... and with the official pypi website / locale en-US + # ... and with the official pypi website - LOCALE='en-US' before_install: - if [ "$TRAVIS_OS_NAME" == "linux" ]; then /sbin/start-stop-daemon --start --quiet --make-pidfile --pidfile /tmp/custom_xvfb_99.pid --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x768x24 ; fi install: - # We need to either pin our marionette version or get every dependent package from - # tree to avoid bustage. Pinning marionette means we're more likely to work out of the - # the box for those working locally without a clone of m-c. - # - svn checkout https://github.com/mozilla/gecko-dev/trunk/testing/marionette/client - # - "cd client && python setup.py develop && cd .." - - python create_venv.py $PIP_STRICT_VERSIONS --with-optional-packages ~/.venv - source ~/.venv/bin/activate @@ -43,15 +37,15 @@ before_script: # Run pep8 on all except the checked out marionette-client folder - pep8 --config ./.pep8.rc --exclude=client . - # Prepare the build and everything else - - mozdownload --type tinderbox --branch $MOZ_BRANCH --locale $LOCALE + # Get the latest build and install it. Store the binary path in binary.txt + - python .travis/download-and-install.py script: - # Run in non-e10s mode - - firefox-ui-tests --installer *firefox-* --gecko-log - + # Run the tests with e10s disabled + - cat binary.txt | xargs -I binary_path firefox-ui-tests --binary binary_path --gecko-log - # Run in e10s mode - - firefox-ui-tests --installer *firefox-* --gecko-log - --e10s + - cat binary.txt | xargs -I binary_path firefox-ui-tests --binary binary_path --gecko-log - --e10s notifications: irc: diff --git a/.travis/download-and-install.py b/.travis/download-and-install.py new file mode 100644 index 00000000..adcb4a2c --- /dev/null +++ b/.travis/download-and-install.py @@ -0,0 +1,21 @@ +#!/bin/env 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/. + +import os + +from mozdownload import FactoryScraper +import mozinstall + + +scraper = FactoryScraper('tinderbox', + branch=os.environ['MOZ_BRANCH'], + locale=os.environ['LOCALE']) +installer_path = scraper.download() + +install_path = mozinstall.install(installer_path, 'application') +binary_path = mozinstall.get_binary(install_path, 'firefox') + +with open('binary.txt', 'w') as f: + f.write(binary_path) diff --git a/firefox_ui_harness/arguments/base.py b/firefox_ui_harness/arguments/base.py index 6f195691..e9520897 100644 --- a/firefox_ui_harness/arguments/base.py +++ b/firefox_ui_harness/arguments/base.py @@ -10,23 +10,9 @@ class FirefoxUIBaseArguments(object): name = 'Firefox UI Tests' - args = [ - [['--installer'], { - 'help': 'Installer of a Gecko application to use for running the tests' - }], - ] + args = [] def parse_args_handler(self, args): - # Bug 1142064 - We cannot easily extent options because registered handlers - # are called at the end in BaseMarionetteArguments.verify_usage(). As result it - # will abort due to no binary specified. Once the bug is fixed we can move - # the whole block to verify_usage_handler(). - if args.installer: - if args.binary: - raise ValueError('Options --binary and --installer are mutually exclusive.') - - args.binary = 'FAKED_VALUE' - # If no tests are specified fall back to puppeteer unit and all firefox ui tests args.tests = args.tests or [firefox_puppeteer.manifest, firefox_ui_tests.manifest_all] diff --git a/firefox_ui_harness/arguments/update.py b/firefox_ui_harness/arguments/update.py index bcc0788d..379537cf 100644 --- a/firefox_ui_harness/arguments/update.py +++ b/firefox_ui_harness/arguments/update.py @@ -51,14 +51,14 @@ class UpdateBaseArguments(object): }], ] + def verify_usage_handler(self, args): + if args.update_direct_only and args.update_fallback_only: + raise ValueError('Arguments --update-direct-only and --update-fallback-only ' + 'are mutually exclusive.') + class UpdateArguments(FirefoxUIArguments): def __init__(self, **kwargs): FirefoxUIArguments.__init__(self, **kwargs) self.register_argument_container(UpdateBaseArguments()) - - def verify_usage(self, args): - if args.update_direct_only and args.update_fallback_only: - raise ValueError('Arguments --update-direct-only and --update-fallback-only ' - 'are mutually exclusive.') diff --git a/firefox_ui_harness/runners/base.py b/firefox_ui_harness/runners/base.py index a726ca49..2388a7d9 100644 --- a/firefox_ui_harness/runners/base.py +++ b/firefox_ui_harness/runners/base.py @@ -3,7 +3,10 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import os +import shutil +import tempfile +import mozfile import mozinfo from marionette import BaseMarionetteTestRunner @@ -21,6 +24,20 @@ def __init__(self, **kwargs): self.test_handlers = [FirefoxTestCase] + def duplicate_application(self, application_folder): + """Creates a copy of the specified binary.""" + + if self.workspace: + target_folder = os.path.join(self.workspace_path, 'application.copy') + else: + target_folder = tempfile.mkdtemp('.application.copy') + + self.logger.info('Creating a copy of the application at "%s".' % target_folder) + mozfile.remove(target_folder) + shutil.copytree(application_folder, target_folder) + + return target_folder + def get_application_folder(self, binary): """Returns the directory of the application.""" if mozinfo.isMac: diff --git a/firefox_ui_harness/runners/update.py b/firefox_ui_harness/runners/update.py index ce4b7fa2..cee24d3f 100644 --- a/firefox_ui_harness/runners/update.py +++ b/firefox_ui_harness/runners/update.py @@ -2,8 +2,6 @@ # 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/. -import os -import shutil import sys import mozfile @@ -38,23 +36,8 @@ def __init__(self, **kwargs): self.run_direct_update = not kwargs.pop('update_fallback_only', False) self.run_fallback_update = not kwargs.pop('update_direct_only', False) - # Used in case no workspace is set - self.installer_workspace = kwargs.pop('installer_workspace', - self.workspace_path) - self.test_handlers = [UpdateTestCase] - def duplicate_application(self, application_folder): - """Creates a copy of the specified binary.""" - - target_folder = os.path.join(self.installer_workspace, 'binary.backup') - - self.logger.info('Creating a copy of the application at "%s".' % target_folder) - mozfile.remove(target_folder) - shutil.copytree(application_folder, target_folder) - - return target_folder - def run_tests(self, tests): # Used to store the last occurred exception because we execute # run_tests() multiple times @@ -66,11 +49,11 @@ def run_tests(self, tests): results = {} def _run_tests(manifest): - target_folder = None + application_folder = None try: - target_folder = self.duplicate_application(source_folder) - self.bin = mozinstall.get_binary(target_folder, 'Firefox') + application_folder = self.duplicate_application(source_folder) + self.bin = mozinstall.get_binary(application_folder, 'Firefox') FirefoxUITestRunner.run_tests(self, [manifest]) @@ -80,9 +63,9 @@ def _run_tests(manifest): exc_info=self.exc_info) finally: - self.logger.info('Removing copy of the application at "%s"' % target_folder) + self.logger.info('Removing copy of the application at "%s"' % application_folder) try: - mozfile.remove(target_folder) + mozfile.remove(application_folder) except IOError as e: self.logger.error('Cannot remove copy of application: "%s"' % str(e)) diff --git a/firefox_ui_harness/runtests.py b/firefox_ui_harness/runtests.py index d9685ae6..da72067e 100644 --- a/firefox_ui_harness/runtests.py +++ b/firefox_ui_harness/runtests.py @@ -2,12 +2,8 @@ # 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/. -import os import sys -import tempfile -import mozfile -import mozinstall import mozlog from marionette.runtests import MarionetteHarness, cli as mn_cli @@ -27,50 +23,9 @@ def __init__(self, logger.error('Failure setting up harness', exc_info=True) raise - self.install_folder = None - - def process_args(self): - # TODO move installer to mozharness script. - # If the specified binary is an installer it needs to be installed - if self.args.installer: - installer = os.path.realpath(self.args.installer) - - if not self.args.workspace: - self.args.installer_workspace = tempfile.mkdtemp( - '.{}'.format(os.path.basename(sys.argv[0])) - ) - else: - self.args.installer_workspace = self.args.workspace - dest_folder = os.path.join(self.args.installer_workspace, 'binary') - self.args.logger.info( - 'Installing application "%s" to "%s"' % (installer, dest_folder) - ) - self.install_folder = mozinstall.install(installer, dest_folder) - self.args.binary = mozinstall.get_binary(self.install_folder, - 'firefox') - def parse_args(self, *args, **kwargs): return MarionetteHarness.parse_args(self, {'mach': sys.stdout}) - def run(self): - try: - return MarionetteHarness.run(self) - finally: - # Ensure to uninstall the binary if it has been installed before - if self.install_folder and os.path.exists(self.install_folder): - self.args.logger.info('Uninstalling application at ' - '"%s"' % self.install_folder) - mozinstall.uninstall(self.install_folder) - if not self.args.workspace: - self.args.logger.info( - 'Removing temporary installer workspace ' - 'at "%s"' % self.args.installer_workspace - ) - try: - mozfile.remove(self.args.installer_workspace) - except IOError as e: - self.logger.error('Cannot remove "%s"' % str(e)) - def cli(): mn_cli(runner_class=FirefoxUITestRunner,