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

Unified Diff: tools/testing/run_selenium.py

Issue 9960018: Various perf/selenium script cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: tools/testing/run_selenium.py
diff --git a/tools/testing/run_selenium.py b/tools/testing/run_selenium.py
index dc05b104e04a37b877d31e71eb55dd9ceae46dc2..b092971bb1440a1a74a7bb7145c6cc52aa5b1812 100755
--- a/tools/testing/run_selenium.py
+++ b/tools/testing/run_selenium.py
@@ -71,17 +71,17 @@ CONFIGURATIONS = {
'dromaeo': dromaeo_test_done
}
-def run_test_in_browser(browser, html_out, timeout, config):
+def run_test_in_browser(browser, html_out, timeout, mode):
"""Run the desired test in the browser using Selenium 2.0 WebDriver syntax,
and wait for the test to complete. This is the newer syntax, that currently
supports Firefox, Chrome, IE, Opera (and some mobile browsers)."""
if isinstance(browser, selenium.selenium):
- return run_test_in_browser_selenium_rc(browser, html_out, timeout, config)
+ return run_test_in_browser_selenium_rc(browser, html_out, timeout, mode)
browser.get("file://" + html_out)
source = ''
try:
- test_done = CONFIGURATIONS[config]
+ test_done = CONFIGURATIONS[mode]
element = WebDriverWait(browser, float(timeout)).until(
lambda driver: test_done(driver.page_source))
source = browser.page_source
@@ -89,13 +89,13 @@ def run_test_in_browser(browser, html_out, timeout, config):
source = TIMEOUT_ERROR_MSG
return source
-def run_test_in_browser_selenium_rc(sel, html_out, timeout, config):
+def run_test_in_browser_selenium_rc(sel, html_out, timeout, mode):
""" Run the desired test in the browser using Selenium 1.0 syntax, and wait
for the test to complete. This is used for Safari, since it is not currently
supported on Selenium 2.0."""
sel.open('file://' + html_out)
source = sel.get_html_source()
- end_condition = CONFIGURATIONS[config]
+ end_condition = CONFIGURATIONS[mode]
elapsed = 0
while (not end_condition(source)) and elapsed <= timeout:
@@ -119,21 +119,11 @@ def parse_args(args=None):
parser.add_option('--timeout', dest = 'timeout',
help = 'Amount of time (seconds) to wait before timeout', type = 'int',
action = 'store', default=58)
- parser.add_option('--perf', dest = 'is_perf',
- help = 'Add this flag if we are running a browser performance test',
- action = 'store_true', default=False)
- # TODO(vsm): Abstract this out better.
- parser.add_option('--dromaeo', dest = 'is_dromaeo',
- help = 'Add this flag if we are running a browser performance test',
- action = 'store_true', default=False)
+ parser.add_option('--mode', dest = 'mode',
+ help = 'The type of test we are running',
+ action = 'store', default='correctness')
args, ignored = parser.parse_args(args=args)
- if args.is_perf:
- config = 'perf'
- elif args.is_dromaeo:
- config = 'dromaeo'
- else:
- config = 'correctness'
- return args.out, args.browser, args.timeout, config
+ return args.out, args.browser, args.timeout, args.mode
def start_browser(browser, html_out):
if browser == 'chrome':
@@ -184,9 +174,9 @@ def close_browser(browser):
# TODO(efortuna): Figure out why this crashes.... and avoid?
pass
-def report_results(config, source):
+def report_results(mode, source):
# TODO(vsm): Add a failure check for Dromaeo.
- if config != 'correctness':
+ if mode != 'correctness':
# We're running a performance test.
print source.encode('utf8')
sys.stdout.flush()
@@ -245,10 +235,10 @@ def run_batch_tests():
if line == '--terminate\n':
break
- html_out, browser_name, timeout, config = parse_args(line.split())
+ html_out, browser_name, timeout, mode = parse_args(line.split())
# Sanity checks that test.dart is passing flags we can handle.
- if config != 'correctness':
+ if mode != 'correctness':
print 'Batch test runner not compatible with perf testing'
return 1
if browser and current_browser_name != browser_name:
@@ -261,7 +251,7 @@ def run_batch_tests():
current_browser_name = browser_name
browser = start_browser(browser_name, html_out)
- source = run_test_in_browser(browser, html_out, timeout, config)
+ source = run_test_in_browser(browser, html_out, timeout, mode)
# Test is done. Write end token to stderr and flush.
sys.stderr.write('>>> EOF STDERR\n')
@@ -269,7 +259,7 @@ def run_batch_tests():
# print one of:
# >>> TEST {PASS, FAIL, OK, CRASH, FAIL, TIMEOUT}
- status = report_results(config, source)
+ status = report_results(mode, source)
if status == 0:
print '>>> TEST PASS'
elif source == TIMEOUT_ERROR_MSG:
@@ -288,12 +278,12 @@ def main(args):
return run_batch_tests()
# Run a single test
- html_out, browser_name, timeout, config = parse_args()
+ html_out, browser_name, timeout, mode = parse_args()
browser = start_browser(browser_name, html_out)
try:
- output = run_test_in_browser(browser, html_out, timeout, config)
- return report_results(config, output)
+ output = run_test_in_browser(browser, html_out, timeout, mode)
+ return report_results(mode, output)
finally:
close_browser(browser)
« tools/testing/perf_testing/run_perf_tests.py ('K') | « tools/testing/perf_testing/run_perf_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698