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

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

Issue 11275125: Prevent hanging if selenium cannot close browser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 22 matching lines...) Expand all
33 import selenium 33 import selenium
34 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities 34 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
35 from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver 35 from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
36 from selenium.webdriver.support.ui import WebDriverWait 36 from selenium.webdriver.support.ui import WebDriverWait
37 import shutil 37 import shutil
38 import signal 38 import signal
39 import socket 39 import socket
40 import sys 40 import sys
41 import time 41 import time
42 import urllib2 42 import urllib2
43 import threading
43 44
44 TIMEOUT_ERROR_MSG = 'FAIL (timeout)' 45 TIMEOUT_ERROR_MSG = 'FAIL (timeout)'
45 46
46 def correctness_test_done(source): 47 def correctness_test_done(source):
47 """Checks if test has completed.""" 48 """Checks if test has completed."""
48 return ('PASS' in source) or ('FAIL' in source) 49 return ('PASS' in source) or ('FAIL' in source)
49 50
50 def perf_test_done(source): 51 def perf_test_done(source):
51 """Tests to see if our performance test is done by printing a score.""" 52 """Tests to see if our performance test is done by printing a score."""
52 #This code is written this way to work around a current instability in the 53 #This code is written this way to work around a current instability in the
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 # >>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT} 309 # >>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}
309 status = report_results(mode, source, browser) 310 status = report_results(mode, source, browser)
310 if status == 0: 311 if status == 0:
311 print '>>> TEST PASS' 312 print '>>> TEST PASS'
312 elif source == TIMEOUT_ERROR_MSG: 313 elif source == TIMEOUT_ERROR_MSG:
313 print '>>> TEST TIMEOUT' 314 print '>>> TEST TIMEOUT'
314 else: 315 else:
315 print '>>> TEST FAIL' 316 print '>>> TEST FAIL'
316 sys.stdout.flush() 317 sys.stdout.flush()
317 finally: 318 finally:
319 sys.stdin.close()
318 print("Closing browser"); 320 print("Closing browser");
319 close_browser(browser)
320 321
322 def close_output_streams:
323 sys.stdout.flush()
324 sys.stdout.close()
325 sys.stderr.flush()
326 sys.stderr.close()
327
328 def close_and_exit:
329 print("Timed out waiting for browser to close")
330 close_output_streams()
331 exit(1)
332
333 timer = threading.Timer(5.0, close_and_exit)
334 timer.start()
335 try:
336 close_browser(browser)
337 timer.cancel()
338 finally:
339 close_output_streams()
321 340
322 def main(args): 341 def main(args):
323 # Run in batch mode if the --batch flag is passed. 342 # Run in batch mode if the --batch flag is passed.
324 # TODO(jmesserly): reconcile with the existing args parsing 343 # TODO(jmesserly): reconcile with the existing args parsing
325 if '--batch' in args: 344 if '--batch' in args:
326 return run_batch_tests() 345 return run_batch_tests()
327 346
328 # Run a single test 347 # Run a single test
329 html_out, browser_name, executable_path, timeout, mode = parse_args() 348 html_out, browser_name, executable_path, timeout, mode = parse_args()
330 browser = start_browser(browser_name, executable_path, html_out) 349 browser = start_browser(browser_name, executable_path, html_out)
331 350
332 try: 351 try:
333 output = run_test_in_browser(browser, html_out, timeout, mode) 352 output = run_test_in_browser(browser, html_out, timeout, mode)
334 return report_results(mode, output, browser) 353 return report_results(mode, output, browser)
335 finally: 354 finally:
336 close_browser(browser) 355 close_browser(browser)
337 356
338 if __name__ == "__main__": 357 if __name__ == "__main__":
339 sys.exit(main(sys.argv)) 358 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