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

Unified Diff: chrome/test/chromedriver/test.py

Issue 11778011: [chromedriver]Add a filter to run a subset of tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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
« no previous file with comments | « chrome/test/chromedriver/run_all_tests.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
« no previous file with comments | « chrome/test/chromedriver/run_all_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698