Index: chrome/test/chromedriver/test.py |
diff --git a/chrome/test/chromedriver/test.py b/chrome/test/chromedriver/test.py |
index e8fe41dbaf3646e73ef892af9f8ff5963d849c47..a942c39e15260a454ccf413ce658e628802eedc3 100644 |
--- a/chrome/test/chromedriver/test.py |
+++ b/chrome/test/chromedriver/test.py |
@@ -5,12 +5,18 @@ |
"""End to end tests for ChromeDriver.""" |
import ctypes |
+import optparse |
import os |
import sys |
import unittest |
import chromedriver |
+_THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
+sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) |
+ |
+from common import unittest_util |
+ |
class ChromeDriverTest(unittest.TestCase): |
"""End to end tests for ChromeDriver.""" |
@@ -47,18 +53,34 @@ class ChromeDriverTest(unittest.TestCase): |
if __name__ == '__main__': |
- if len(sys.argv) != 2 and len(sys.argv) != 3: |
- print ('Usage: %s <path_to_chromedriver_so> [path_to_chrome_binary]' % |
- __file__) |
- sys.exit(1) |
+ parser = optparse.OptionParser() |
kkania
2013/01/06 22:13:09
if you want, go ahead and change this file to exec
|
+ parser.add_option( |
+ '', '--chromedriver_path', type='string', default=None, |
kkania
2013/01/06 22:13:09
most chromium uses chromedriver-path style args; c
|
+ help='Path to a build of the chromedriver library(REQUIRED!)') |
+ parser.add_option( |
+ '', '--chrome_path', type='string', default=None, |
+ help='Path to a build of the chrome binary') |
+ parser.add_option( |
+ '', '--gtest_filter', type='string', default='*', |
+ help='Filter for specifying what tests to run, "*" will run all. E.g., ' + |
+ '*testStartStop') |
+ options, args = parser.parse_args() |
+ |
+ if (options.chromedriver_path is None or |
+ not os.path.exists(options.chromedriver_path)): |
+ parser.error('chromedriver_path is required or the given path is invalid.' + |
+ 'Please run "%s --help" for help' % __file__) |
+ |
global _CHROMEDRIVER_LIB |
- _CHROMEDRIVER_LIB = os.path.abspath(sys.argv[1]) |
+ _CHROMEDRIVER_LIB = os.path.abspath(options.chromedriver_path) |
global _CHROME_BINARY |
- if len(sys.argv) == 3: |
- _CHROME_BINARY = os.path.abspath(sys.argv[2]) |
+ if options.chrome_path is not None: |
+ _CHROME_BINARY = os.path.abspath(options.chrome_path) |
else: |
_CHROME_BINARY = None |
+ |
all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( |
sys.modules[__name__]) |
- result = unittest.TextTestRunner().run(all_tests_suite) |
+ tests = unittest_util.FilterTestSuite(all_tests_suite, options.gtest_filter) |
+ result = unittest.TextTestRunner().run(tests) |
sys.exit(len(result.failures) + len(result.errors)) |