Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: tools/testing/run_selenium.py

Issue 11826023: Print exception information in run_selenium.py. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 7
8 """Script to actually open a browser and perform the test, and reports back with 8 """Script to actually open a browser and perform the test, and reports back with
9 the result. It uses Selenium WebDriver when possible for running the tests. It 9 the result. It uses Selenium WebDriver when possible for running the tests. It
10 uses Selenium RC for Safari. 10 uses Selenium RC for Safari.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 print '>>> BATCH START' 279 print '>>> BATCH START'
280 browser = None 280 browser = None
281 current_browser_name = None 281 current_browser_name = None
282 282
283 # TODO(jmesserly): It'd be nice to shutdown gracefully in the event of a 283 # TODO(jmesserly): It'd be nice to shutdown gracefully in the event of a
284 # SIGTERM. Unfortunately dart:io cannot send SIGTERM, see dartbug.com/1756. 284 # SIGTERM. Unfortunately dart:io cannot send SIGTERM, see dartbug.com/1756.
285 signal.signal(signal.SIGTERM, lambda number, frame: close_browser(browser)) 285 signal.signal(signal.SIGTERM, lambda number, frame: close_browser(browser))
286 286
287 try: 287 try:
288 while True: 288 try:
289 line = sys.stdin.readline() 289 while True:
290 if line == '--terminate\n': 290 line = sys.stdin.readline()
291 print("Terminating selenium driver") 291 if line == '--terminate\n':
292 break 292 print("Terminating selenium driver")
293 break
293 294
294 (html_out, browser_name, executable_path, 295 (html_out, browser_name, executable_path,
295 timeout, mode, refresh) = parse_args(line.split()) 296 timeout, mode, refresh) = parse_args(line.split())
296 297
297 # Sanity checks that test.dart is passing flags we can handle. 298 # Sanity checks that test.dart is passing flags we can handle.
298 if mode != 'correctness': 299 if mode != 'correctness':
299 print 'Batch test runner not compatible with perf testing' 300 print 'Batch test runner not compatible with perf testing'
300 return 1 301 return 1
301 if browser and current_browser_name != browser_name: 302 if browser and current_browser_name != browser_name:
302 print('Batch test runner got multiple browsers: %s and %s' 303 print('Batch test runner got multiple browsers: %s and %s'
303 % (current_browser_name, browser_name)) 304 % (current_browser_name, browser_name))
304 return 1 305 return 1
305 306
306 # Start the browser on the first run 307 # Start the browser on the first run
307 if browser is None: 308 if browser is None:
308 current_browser_name = browser_name 309 current_browser_name = browser_name
309 browser = start_browser(browser_name, executable_path, html_out) 310 browser = start_browser(browser_name, executable_path, html_out)
310 311
311 source = run_test_in_browser(browser, html_out, timeout, mode, refresh) 312 source = run_test_in_browser(browser, html_out, timeout, mode, refresh)
312 313
313 # Test is done. Write end token to stderr and flush. 314 # Test is done. Write end token to stderr and flush.
314 sys.stderr.write('>>> EOF STDERR\n') 315 sys.stderr.write('>>> EOF STDERR\n')
315 sys.stderr.flush() 316 sys.stderr.flush()
316 317
317 # print one of: 318 # print one of:
318 # >>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT} 319 # >>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}
319 status = report_results(mode, source, browser) 320 status = report_results(mode, source, browser)
320 if status == 0: 321 if status == 0:
321 print '>>> TEST PASS' 322 print '>>> TEST PASS'
322 elif source == TIMEOUT_ERROR_MSG: 323 elif source == TIMEOUT_ERROR_MSG:
323 print '>>> TEST TIMEOUT' 324 print '>>> TEST TIMEOUT'
324 else: 325 else:
325 print '>>> TEST FAIL' 326 print '>>> TEST FAIL'
326 sys.stdout.flush() 327 sys.stdout.flush()
328 except:
329 type, value, traceback = sys.exc_info()
330 print "run_selenium.py: Unexpected exception occured: "
331 print " type: ", type
332 print " value: ", value
333 print " traceback: ", traceback
334 raise
327 finally: 335 finally:
328 sys.stdin.close() 336 sys.stdin.close()
329 print("Closing browser"); 337 print("Closing browser");
330 338
331 def close_output_streams(): 339 def close_output_streams():
332 sys.stdout.flush() 340 sys.stdout.flush()
333 sys.stdout.close() 341 sys.stdout.close()
334 sys.stderr.flush() 342 sys.stderr.flush()
335 sys.stderr.close() 343 sys.stderr.close()
336 344
(...skipping 21 matching lines...) Expand all
358 browser = start_browser(browser_name, executable_path, html_out) 366 browser = start_browser(browser_name, executable_path, html_out)
359 367
360 try: 368 try:
361 output = run_test_in_browser(browser, html_out, timeout, mode, refresh) 369 output = run_test_in_browser(browser, html_out, timeout, mode, refresh)
362 return report_results(mode, output, browser) 370 return report_results(mode, output, browser)
363 finally: 371 finally:
364 close_browser(browser) 372 close_browser(browser)
365 373
366 if __name__ == "__main__": 374 if __name__ == "__main__":
367 sys.exit(main(sys.argv)) 375 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698