OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import glob | 6 import glob |
7 import optparse | 7 import optparse |
8 import os.path | 8 import os.path |
9 import sys | 9 import sys |
10 import thread | 10 import thread |
(...skipping 20 matching lines...) Expand all Loading... |
31 default='0', help='The TCP port the server will bind to. ' | 31 default='0', help='The TCP port the server will bind to. ' |
32 'The default is to pick an unused port number.') | 32 'The default is to pick an unused port number.') |
33 parser.add_option('--browser_path', dest='browser_path', action='store', | 33 parser.add_option('--browser_path', dest='browser_path', action='store', |
34 type='string', default=None, | 34 type='string', default=None, |
35 help='Use the browser located here.') | 35 help='Use the browser located here.') |
36 parser.add_option('--map_file', dest='map_files', action='append', | 36 parser.add_option('--map_file', dest='map_files', action='append', |
37 type='string', nargs=2, default=[], | 37 type='string', nargs=2, default=[], |
38 metavar='DEST SRC', | 38 metavar='DEST SRC', |
39 help='Add file SRC to be served from the HTTP server, ' | 39 help='Add file SRC to be served from the HTTP server, ' |
40 'to be made visible under the path DEST.') | 40 'to be made visible under the path DEST.') |
| 41 parser.add_option('--serving_dir', dest='serving_dirs', action='append', |
| 42 type='string', default=[], |
| 43 metavar='DIRNAME', |
| 44 help='Add directory DIRNAME to be served from the HTTP ' |
| 45 'server to be made visible under the root.') |
41 parser.add_option('--test_arg', dest='test_args', action='append', | 46 parser.add_option('--test_arg', dest='test_args', action='append', |
42 type='string', nargs=2, default=[], | 47 type='string', nargs=2, default=[], |
43 metavar='KEY VALUE', | 48 metavar='KEY VALUE', |
44 help='Parameterize the test with a key/value pair.') | 49 help='Parameterize the test with a key/value pair.') |
45 parser.add_option('--redirect_url', dest='map_redirects', action='append', | 50 parser.add_option('--redirect_url', dest='map_redirects', action='append', |
46 type='string', nargs=2, default=[], | 51 type='string', nargs=2, default=[], |
47 metavar='DEST SRC', | 52 metavar='DEST SRC', |
48 help='Add a redirect to the HTTP server, ' | 53 help='Add a redirect to the HTTP server, ' |
49 'requests for SRC will result in a redirect (302) to DEST.') | 54 'requests for SRC will result in a redirect (302) to DEST.') |
50 parser.add_option('--enable_experimental_js', dest='enable_experimental_js', | 55 parser.add_option('--enable_experimental_js', dest='enable_experimental_js', |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 def ShutdownCallback(): | 155 def ShutdownCallback(): |
151 server.TestingEnded() | 156 server.TestingEnded() |
152 close_browser = options.tool is not None and not options.interactive | 157 close_browser = options.tool is not None and not options.interactive |
153 return close_browser | 158 return close_browser |
154 | 159 |
155 listener = browsertester.rpclistener.RPCListener(ShutdownCallback) | 160 listener = browsertester.rpclistener.RPCListener(ShutdownCallback) |
156 server.Configure(file_mapping, | 161 server.Configure(file_mapping, |
157 dict(options.map_redirects), | 162 dict(options.map_redirects), |
158 options.allow_404, | 163 options.allow_404, |
159 options.bandwidth, | 164 options.bandwidth, |
160 listener) | 165 listener, |
| 166 options.serving_dirs) |
161 | 167 |
162 browser = browsertester.browserlauncher.ChromeLauncher(options) | 168 browser = browsertester.browserlauncher.ChromeLauncher(options) |
163 | 169 |
164 full_url = 'http://%s:%d/%s' % (host, port, url) | 170 full_url = 'http://%s:%d/%s' % (host, port, url) |
165 if len(options.test_args) > 0: | 171 if len(options.test_args) > 0: |
166 full_url += '?' + urllib.urlencode(options.test_args) | 172 full_url += '?' + urllib.urlencode(options.test_args) |
167 browser.Run(full_url, port) | 173 browser.Run(full_url, port) |
168 server.TestingBegun(0.125) | 174 server.TestingBegun(0.125) |
169 | 175 |
170 # In Python 2.5, server.handle_request may block indefinitely. Serving pages | 176 # In Python 2.5, server.handle_request may block indefinitely. Serving pages |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 return 1 | 222 return 1 |
217 else: | 223 else: |
218 return 0 | 224 return 0 |
219 | 225 |
220 | 226 |
221 def RunFromCommandLine(): | 227 def RunFromCommandLine(): |
222 parser = BuildArgParser() | 228 parser = BuildArgParser() |
223 options, args = parser.parse_args() | 229 options, args = parser.parse_args() |
224 | 230 |
225 if len(args) != 0: | 231 if len(args) != 0: |
| 232 print args |
226 parser.error('Invalid arguments') | 233 parser.error('Invalid arguments') |
227 | 234 |
228 # Validate the URL | 235 # Validate the URL |
229 url = options.url | 236 url = options.url |
230 if url is None: | 237 if url is None: |
231 parser.error('Must specify a URL') | 238 parser.error('Must specify a URL') |
232 | 239 |
233 if options.hard_timeout is None: | 240 if options.hard_timeout is None: |
234 options.hard_timeout = options.timeout * 3 | 241 options.hard_timeout = options.timeout * 3 |
235 | 242 |
236 return Run(url, options) | 243 return Run(url, options) |
237 | 244 |
238 | 245 |
239 if __name__ == '__main__': | 246 if __name__ == '__main__': |
240 sys.exit(RunFromCommandLine()) | 247 sys.exit(RunFromCommandLine()) |
OLD | NEW |