1
#!${buildout:executable} -S
2
# Copyright 2009 Canonical Ltd. This software is licensed under the
3
# GNU Affero General Public License version 3 (see the file LICENSE).
6
A script for running all of the windmill JavaScript integration test suites
7
in Launchpad. Aggregates the result of running each suite into a global
10
The script exit codes are:
17
# Initialize our paths.
18
${python-relative-path-setup}
20
sys.path.insert(0, ${scripts:parts-directory|path-repr})
25
from lp.scripts.utilities.lpwindmill import runLaunchpad
28
# Test runner configuration hash
30
'runner': 'bin/windmill',
35
# A hash of test suites to run. Each key has two parts: the path to the test
36
# suite root directory (relative to the test root directory) and the domain
37
# that the test runner must use during suite execution.
40
'suite_dir': 'lib/canonical/launchpad/windmill/tests/test_registry',
41
'domain': 'launchpad.dev'
44
'suite_dir': 'lib/lp/bugs/windmill',
45
'domain': 'bugs.launchpad.dev'
48
'suite_dir': 'lib/lp/code/windmill',
49
'domain': 'code.launchpad.dev'
52
'suite_dir': 'lib/lp/soyuz/windmill',
53
'domain': 'launchpad.dev'
56
'suite_dir': 'lib/lp/translations/windmill',
57
'domain': 'translations.launchpad.dev'
62
def run_suite(suite_config):
63
"""Run a JavaScript test suite using the given suite configuration."""
64
config = runner_config.copy()
65
config['url'] = 'http://%s:%s' % (
66
suite_config['domain'],
67
runner_config['port'])
68
config['suite'] = suite_config['suite_dir']
70
# Do we have a test runner?
71
if not os.path.exists(config['runner']):
73
"Error: Couldn't find the testrunner executable: %s\n" % (
77
# Do we have a test suite?
78
if not os.path.exists(config['suite']):
80
"Error: Couldn't find the test suite: %s\n" % config['suite'])
83
# The final test runner call.
84
# Should be something like: windmill -e test=foo/bar firefox http://blah
85
# Pass '-e' to the runner so it exits after suite completion.
89
"test=%s" % config['suite'],
95
return subprocess.call(test_command)
98
"Error: Test command failed to execute: " + test_command + "\n")
99
sys.stderr.write("Exiting\n")
103
def run_all_windmills():
104
"""Run all of the available test suites.
106
Returns the number of test suites that failed.
108
# Set up the launchpad instance, and install the atexit handlers that
109
# will clean everything up when this script exits.
114
for suite_name, suite_config in test_suites.items():
115
print "Running the %s test suite" % suite_name
117
exit_status = run_suite(suite_config)
120
print "Failure: Test failures in the %s test suite" % suite_name
127
if __name__ == '__main__':
128
failures = run_all_windmills()
130
print "Failed: %d test suites failed" % failures
133
print "Success: all suites passed"