Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Bug 1227570 - Remove support of the --installer command line option. …
Browse files Browse the repository at this point in the history
…r=maja_zf

(cherry picked from commit 0121c2a)
  • Loading branch information
whimboo committed Dec 15, 2015
1 parent 5c3065c commit 2ea9771
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 101 deletions.
22 changes: 8 additions & 14 deletions .travis.yml
Expand Up @@ -16,42 +16,36 @@ 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

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:
Expand Down
21 changes: 21 additions & 0 deletions .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)
16 changes: 1 addition & 15 deletions firefox_ui_harness/arguments/base.py
Expand Up @@ -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]

Expand Down
10 changes: 5 additions & 5 deletions firefox_ui_harness/arguments/update.py
Expand Up @@ -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.')
17 changes: 17 additions & 0 deletions firefox_ui_harness/runners/base.py
Expand Up @@ -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

Expand All @@ -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:
Expand Down
27 changes: 5 additions & 22 deletions firefox_ui_harness/runners/update.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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])

Expand All @@ -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))

Expand Down
45 changes: 0 additions & 45 deletions firefox_ui_harness/runtests.py
Expand Up @@ -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

Expand All @@ -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,
Expand Down

0 comments on commit 2ea9771

Please sign in to comment.