10713.1.1
by Gary Poster
use new version of z3c.recipe.filetemplate and zc.buildout fork to use relative paths. |
1 |
#!${buildout:executable} -S
|
8687.15.34
by Karl Fogel
Add license header blocks to .py, .zcml, and .pt files that don't have it |
2 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
3 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
4 |
||
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
5 |
"""
|
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
|
|
8 |
pass or fail value.
|
|
9 |
||
10 |
The script exit codes are:
|
|
11 |
0: suite success
|
|
12 |
1: suite error
|
|
13 |
2: suite failure
|
|
14 |
||
15 |
"""
|
|
16 |
||
10713.1.1
by Gary Poster
use new version of z3c.recipe.filetemplate and zc.buildout fork to use relative paths. |
17 |
# Initialize our paths.
|
18 |
${python-relative-path-setup} |
|
19 |
import sys |
|
20 |
sys.path.insert(0, ${scripts:parts-directory|path-repr}) |
|
21 |
import site |
|
22 |
||
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
23 |
import subprocess |
24 |
import os |
|
9012.1.5
by Maris Fogels
Made the windmill test runner use the convenience functions from lpwindmill.py |
25 |
from lp.scripts.utilities.lpwindmill import runLaunchpad |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
26 |
|
27 |
||
28 |
# Test runner configuration hash
|
|
29 |
runner_config = { |
|
9012.1.5
by Maris Fogels
Made the windmill test runner use the convenience functions from lpwindmill.py |
30 |
'runner': 'bin/windmill', |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
31 |
'port': 8085, |
32 |
'browser': 'firefox', |
|
33 |
}
|
|
34 |
||
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.
|
|
38 |
test_suites = { |
|
39 |
'registry': { |
|
9012.1.1
by Maris Fogels
Fixed the test suite file paths. |
40 |
'suite_dir': 'lib/canonical/launchpad/windmill/tests/test_registry', |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
41 |
'domain': 'launchpad.dev' |
42 |
},
|
|
43 |
'bugs': { |
|
9012.1.1
by Maris Fogels
Fixed the test suite file paths. |
44 |
'suite_dir': 'lib/lp/bugs/windmill', |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
45 |
'domain': 'bugs.launchpad.dev' |
46 |
},
|
|
9012.1.1
by Maris Fogels
Fixed the test suite file paths. |
47 |
'code': { |
48 |
'suite_dir': 'lib/lp/code/windmill', |
|
49 |
'domain': 'code.launchpad.dev' |
|
50 |
},
|
|
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
51 |
'soyuz': { |
9654.1.2
by Michael Nelson
Moved old windmill test to new default location. |
52 |
'suite_dir': 'lib/lp/soyuz/windmill', |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
53 |
'domain': 'launchpad.dev' |
54 |
},
|
|
55 |
'translations': { |
|
9012.1.1
by Maris Fogels
Fixed the test suite file paths. |
56 |
'suite_dir': 'lib/lp/translations/windmill', |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
57 |
'domain': 'translations.launchpad.dev' |
58 |
},
|
|
59 |
}
|
|
60 |
||
61 |
||
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']) |
|
9012.1.1
by Maris Fogels
Fixed the test suite file paths. |
68 |
config['suite'] = suite_config['suite_dir'] |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
69 |
|
70 |
# Do we have a test runner?
|
|
71 |
if not os.path.exists(config['runner']): |
|
72 |
sys.stderr.write( |
|
73 |
"Error: Couldn't find the testrunner executable: %s\n" % ( |
|
74 |
config['runner'])) |
|
75 |
sys.exit(1) |
|
76 |
||
77 |
# Do we have a test suite?
|
|
78 |
if not os.path.exists(config['suite']): |
|
79 |
sys.stderr.write( |
|
80 |
"Error: Couldn't find the test suite: %s\n" % config['suite']) |
|
81 |
sys.exit(1) |
|
82 |
||
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.
|
|
86 |
test_command = [ |
|
87 |
config['runner'], |
|
88 |
"-e", |
|
89 |
"test=%s" % config['suite'], |
|
90 |
config['browser'], |
|
91 |
config['url'], |
|
92 |
]
|
|
93 |
||
94 |
try: |
|
9012.1.5
by Maris Fogels
Made the windmill test runner use the convenience functions from lpwindmill.py |
95 |
return subprocess.call(test_command) |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
96 |
except OSError, e: |
97 |
sys.stderr.write( |
|
98 |
"Error: Test command failed to execute: " + test_command + "\n") |
|
99 |
sys.stderr.write("Exiting\n") |
|
100 |
sys.exit(1) |
|
101 |
||
102 |
||
103 |
def run_all_windmills(): |
|
104 |
"""Run all of the available test suites.
|
|
105 |
||
106 |
Returns the number of test suites that failed.
|
|
107 |
"""
|
|
9012.1.5
by Maris Fogels
Made the windmill test runner use the convenience functions from lpwindmill.py |
108 |
# Set up the launchpad instance, and install the atexit handlers that
|
109 |
# will clean everything up when this script exits.
|
|
110 |
runLaunchpad() |
|
111 |
||
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
112 |
failures = 0 |
113 |
||
114 |
for suite_name, suite_config in test_suites.items(): |
|
115 |
print "Running the %s test suite" % suite_name |
|
116 |
||
9012.1.5
by Maris Fogels
Made the windmill test runner use the convenience functions from lpwindmill.py |
117 |
exit_status = run_suite(suite_config) |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
118 |
|
9012.1.5
by Maris Fogels
Made the windmill test runner use the convenience functions from lpwindmill.py |
119 |
if exit_status != 0: |
8791.1.1
by Maris Fogels
Added a harness for running all of the windmill test suites in Launchpad. |
120 |
print "Failure: Test failures in the %s test suite" % suite_name |
121 |
print
|
|
122 |
failures += 1 |
|
123 |
||
124 |
return failures |
|
125 |
||
126 |
||
127 |
if __name__ == '__main__': |
|
128 |
failures = run_all_windmills() |
|
129 |
if failures != 0: |
|
130 |
print "Failed: %d test suites failed" % failures |
|
131 |
sys.exit(2) |
|
132 |
else: |
|
133 |
print "Success: all suites passed" |
|
134 |
sys.exit(0) |