mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 568642 - Create make target for make mozmill r=ctalbert a=NPOTB
This commit is contained in:
parent
34a61fbd7f
commit
5144427ff0
@ -64,19 +64,37 @@ TEST_HARNESS_PACKAGES = \
|
||||
mozmill \
|
||||
$(NULL)
|
||||
|
||||
TEST_FILES := \
|
||||
$(TEST_HARNESS_PACKAGES) \
|
||||
MOZMILL_EXTRAS := \
|
||||
virtualenv \
|
||||
README.txt \
|
||||
installmozmill.py \
|
||||
$(NULL)
|
||||
|
||||
TEST_FILES := \
|
||||
$(TEST_HARNESS_PACKAGES) \
|
||||
$(MOZMILL_EXTRAS) \
|
||||
tests \
|
||||
$(NULL)
|
||||
|
||||
# Rules for staging the necessary harness bits for a test package
|
||||
PKG_STAGE = $(DIST)/test-package-stage
|
||||
|
||||
stage-package:
|
||||
# assumes you are in objdir
|
||||
mozmill-dir:
|
||||
$(NSINSTALL) -D $(PKG_STAGE)/mozmill
|
||||
echo $(TEST_HARNESS_PACKAGES) > $(PKG_STAGE)/mozmill/PACKAGES
|
||||
|
||||
install: mozmill-dir
|
||||
(cd $(srcdir) && tar $(TAR_CREATE_FLAGS) - $(TEST_FILES)) | (cd $(PKG_STAGE)/mozmill && tar -xf -)
|
||||
|
||||
# on WINNT, copy the tests; otherwise, assume you can symlink them
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
install-develop: install
|
||||
else
|
||||
install-develop: mozmill-dir
|
||||
$(INSTALL) $(foreach f, $(TEST_HARNESS_PACKAGES), "$(srcdir)/$f") $(PKG_STAGE)/mozmill/
|
||||
(cd $(srcdir) && tar $(TAR_CREATE_FLAGS) - $(MOZMILL_EXTRAS)) | (cd $(PKG_STAGE)/mozmill && tar -xf -)
|
||||
$(INSTALL) $(topsrcdir)/testing/mozmill/tests $(PKG_STAGE)/mozmill
|
||||
endif
|
||||
|
||||
# Rules for staging the necessary harness bits for a test package
|
||||
stage-package: PKG_STAGE = $(DIST)/test-package-stage
|
||||
stage-package: install
|
||||
|
||||
|
@ -43,12 +43,50 @@ install mozmill and its dependencies
|
||||
|
||||
import os
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
from subprocess import call
|
||||
|
||||
### utility functions for cross-platform
|
||||
|
||||
def is_windows():
|
||||
return sys.platform.startswith('win')
|
||||
|
||||
def esc(path):
|
||||
"""quote and escape a path for cross-platform use"""
|
||||
return '"%s"' % repr(path)[1:-1]
|
||||
|
||||
def scripts_path(virtual_env):
|
||||
"""path to scripts directory"""
|
||||
if is_windows():
|
||||
return os.path.join(virtual_env, 'Scripts')
|
||||
return os.path.join(virtual_env, 'bin')
|
||||
|
||||
def python_script_path(virtual_env, script_name):
|
||||
"""path to a python script in a virtualenv"""
|
||||
scripts_dir = scripts_path(virtual_env)
|
||||
if is_windows():
|
||||
script_name = script_name + '-script.py'
|
||||
return os.path.join(scripts_dir, script_name)
|
||||
|
||||
def entry_point_path(virtual_env, entry_point):
|
||||
path = os.path.join(scripts_path(virtual_env), entry_point)
|
||||
if is_windows():
|
||||
path += '.exe'
|
||||
return path
|
||||
|
||||
### command-line entry point
|
||||
|
||||
def main(args=None):
|
||||
"""command line front-end function"""
|
||||
|
||||
# parse command line arguments
|
||||
args = args or sys.argv[1:]
|
||||
usage = "Usage: %prog [options] [destination]"
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option('--develop', dest='develop',
|
||||
action='store_true', default=False,
|
||||
help='setup in development mode')
|
||||
options, args = parser.parse_args(args)
|
||||
|
||||
# Print the python version
|
||||
print 'Python: %s' % sys.version
|
||||
@ -62,37 +100,63 @@ def main(args=None):
|
||||
elif len(args) == 1:
|
||||
destination = os.path.abspath(args[0])
|
||||
else:
|
||||
print "Usage: %s [destination]" % sys.argv[0]
|
||||
sys.exit(1)
|
||||
parser.print_usage()
|
||||
parser.exit(1)
|
||||
|
||||
os.chdir(source)
|
||||
|
||||
# check for existence of necessary files
|
||||
required = ('PACKAGES', 'virtualenv')
|
||||
for f in required:
|
||||
if not os.path.exists(f):
|
||||
print "File not found: " + f
|
||||
sys.exit(1)
|
||||
if not os.path.exists('virtualenv'):
|
||||
print "File not found: virtualenv"
|
||||
sys.exit(1)
|
||||
PACKAGES_FILE = 'PACKAGES'
|
||||
if not os.path.exists(PACKAGES_FILE) and destination != source:
|
||||
PACKAGES_FILE = os.path.join(destination, PACKAGES_FILE)
|
||||
if not os.path.exists(PACKAGES_FILE):
|
||||
print "File not found: PACKAGES"
|
||||
|
||||
# packages to install in dependency order
|
||||
PACKAGES=file('PACKAGES').read().split()
|
||||
PACKAGES=file(PACKAGES_FILE).read().split()
|
||||
assert PACKAGES
|
||||
|
||||
# create the virtualenv and install packages
|
||||
env = os.environ.copy()
|
||||
env.pop('PYTHONHOME', None)
|
||||
returncode = call([sys.executable, 'virtualenv/virtualenv.py', destination], env=env)
|
||||
returncode = call([sys.executable, os.path.join('virtualenv', 'virtualenv.py'), destination], env=env)
|
||||
if returncode:
|
||||
print 'Failure to install virtualenv'
|
||||
sys.exit(returncode)
|
||||
if sys.platform.startswith('win'):
|
||||
pip = os.path.join(destination, 'Scripts', 'pip.exe')
|
||||
if options.develop:
|
||||
python = entry_point_path(destination, 'python')
|
||||
for package in PACKAGES:
|
||||
oldcwd = os.getcwd()
|
||||
os.chdir(package)
|
||||
returncode = call([python, 'setup.py', 'develop'])
|
||||
os.chdir(oldcwd)
|
||||
if returncode:
|
||||
break
|
||||
else:
|
||||
pip = os.path.join(destination, 'bin', 'pip')
|
||||
returncode = call([pip, 'install'] + PACKAGES, env=env)
|
||||
pip = entry_point_path(destination, 'pip')
|
||||
returncode = call([pip, 'install'] + PACKAGES, env=env)
|
||||
|
||||
if returncode:
|
||||
print 'Failure to install packages'
|
||||
sys.exit(returncode)
|
||||
|
||||
# create a front end runner that is path-independent
|
||||
template = """#!/bin/bash
|
||||
unset PYTHONHOME
|
||||
%(PYTHON)s %(MOZMILL)s $@
|
||||
"""
|
||||
variables = {'PYTHON': esc(entry_point_path(destination, 'python')) }
|
||||
for script in 'mozmill', 'mozmill-restart':
|
||||
path = os.path.join(destination, script + '.sh')
|
||||
f = file(path, 'w')
|
||||
variables['MOZMILL'] = esc(python_script_path(destination, script))
|
||||
print >> f, template % variables
|
||||
f.close()
|
||||
if not is_windows():
|
||||
os.chmod(path, 0755)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -100,7 +100,7 @@ def run_setup(with_binary):
|
||||
)
|
||||
|
||||
try:
|
||||
run_setup(True)
|
||||
run_setup(False)
|
||||
except BuildFailed:
|
||||
BUILD_EXT_WARNING = "WARNING: The C extension could not be compiled, speedups are not enabled."
|
||||
print '*' * 75
|
||||
|
@ -45,6 +45,10 @@ else
|
||||
TEST_PATH_ARG :=
|
||||
endif
|
||||
|
||||
# include automation-build.mk to get the path to the binary
|
||||
TARGET_DEPTH = $(DEPTH)
|
||||
include $(topsrcdir)/build/binary-location.mk
|
||||
|
||||
SYMBOLS_PATH := --symbols-path=$(DIST)/crashreporter-symbols
|
||||
|
||||
# Usage: |make [TEST_PATH=...] [EXTRA_TEST_ARGS=...] mochitest*|.
|
||||
@ -138,6 +142,29 @@ xpcshell-tests:
|
||||
$(TEST_PATH_ARG) $(EXTRA_TEST_ARGS) \
|
||||
$(DIST)/bin/xpcshell
|
||||
|
||||
# install and run the mozmill tests
|
||||
$(DEPTH)/_tests/mozmill:
|
||||
$(MAKE) -C $(DEPTH)/testing/mozmill install-develop PKG_STAGE=../../_tests
|
||||
$(PYTHON) $(topsrcdir)/testing/mozmill/installmozmill.py --develop $(DEPTH)/_tests/mozmill
|
||||
|
||||
MOZMILL_TEST_PATH = $(DEPTH)/_tests/mozmill/tests/firefox
|
||||
mozmill: TEST_PATH?=$(MOZMILL_TEST_PATH)
|
||||
mozmill: $(DEPTH)/_tests/mozmill
|
||||
$(SHELL) $(DEPTH)/_tests/mozmill/mozmill.sh -t $(TEST_PATH) -b $(browser_path) --show-all
|
||||
|
||||
MOZMILL_RESTART_TEST_PATH = $(DEPTH)/_tests/mozmill/tests/firefox/restartTests
|
||||
mozmill-restart: TEST_PATH?=$(MOZMILL_RESTART_TEST_PATH)
|
||||
mozmill-restart: $(DEPTH)/_tests/mozmill
|
||||
$(SHELL) $(DEPTH)/_tests/mozmill/mozmill-restart.sh -t $(TEST_PATH) -b $(browser_path) --show-all
|
||||
|
||||
# in order to have `mozmill-all` ignore TEST_PATH, if it is set, we shell out to call make
|
||||
# again, verbosely overriding the TEST_PATH
|
||||
# This isn't as neat as having mozmill and mozmill-restart be dependencies, but it
|
||||
# seems to be the make idiom
|
||||
mozmill-all:
|
||||
$(MAKE) mozmill TEST_PATH=$(MOZMILL_TEST_PATH)
|
||||
$(MAKE) mozmill-restart TEST_PATH=$(MOZMILL_RESTART_TEST_PATH)
|
||||
|
||||
# Package up the tests and test harnesses
|
||||
include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user