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

Unified Diff: chrome/test/chromedriver/run_py_tests.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: Address comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/run_java_tests.py ('k') | chrome/test/chromedriver/test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/run_py_tests.py
diff --git a/chrome/test/chromedriver/test.py b/chrome/test/chromedriver/run_py_tests.py
old mode 100644
new mode 100755
similarity index 60%
rename from chrome/test/chromedriver/test.py
rename to chrome/test/chromedriver/run_py_tests.py
index e8fe41dbaf3646e73ef892af9f8ff5963d849c47..90ee6ee76a57d73b0d42261cc62e9b36a8f07db7
--- a/chrome/test/chromedriver/test.py
+++ b/chrome/test/chromedriver/run_py_tests.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -5,12 +6,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 +54,33 @@ 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()
+ parser.add_option(
+ '', '--chromedriver', type='string', default=None,
+ help='Path to a build of the chromedriver library(REQUIRED!)')
+ parser.add_option(
+ '', '--chrome', type='string', default=None,
+ help='Path to a build of the chrome binary')
+ parser.add_option(
+ '', '--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 is None or not os.path.exists(options.chromedriver)):
+ parser.error('chromedriver 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)
global _CHROME_BINARY
- if len(sys.argv) == 3:
- _CHROME_BINARY = os.path.abspath(sys.argv[2])
+ if options.chrome is not None:
+ _CHROME_BINARY = os.path.abspath(options.chrome)
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.filter)
+ result = unittest.TextTestRunner().run(tests)
sys.exit(len(result.failures) + len(result.errors))
« no previous file with comments | « chrome/test/chromedriver/run_java_tests.py ('k') | chrome/test/chromedriver/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698