| 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))
|
|
|