def main(): usage = "usage: %prog <chromedriver binary> [options]" parser = optparse.OptionParser(usage=usage) parser.add_option("", "--output-log-path", help="Output verbose server logs to this file") parser.add_option("", "--chrome", help="Path to the desired Chrome binary.") parser.add_option( "", "--filter", type="string", default="*", help= "Filter for specifying what tests to run, \"*\" will run all. E.g., " "*testRunMethod") global _OPTIONS, _CHROMEDRIVER _OPTIONS, args = parser.parse_args() _CHROMEDRIVER = util.GetAbsolutePathOfUserPath(args[0]) if not os.path.exists(_CHROMEDRIVER): parser.error("Path given by --chromedriver is invalid.\n" 'Please run "%s --help" for help' % __file__) if _OPTIONS.chrome and not os.path.exists(_OPTIONS.chrome): parser.error("Path given by --chrome is invalid.\n" 'Please run "%s --help" for help' % __file__) all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( sys.modules[__name__]) tests = unittest_util.FilterTestSuite(all_tests_suite, _OPTIONS.filter) result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) sys.exit(len(result.failures) + len(result.errors))
def main(): parser = optparse.OptionParser() parser.add_option( "", "--filter", type="string", default="*", help=( 'Filter for specifying what tests to run, "*" will run all. E.g., ' "*testReplaceUrl_nothing")) parser.add_option("", "--isolated-script-test-output", help="JSON output file used by swarming") # this option is ignored parser.add_option("--isolated-script-test-perf-output", type=str) options, _ = parser.parse_args() all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( sys.modules[__name__]) tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) if options.isolated_script_test_output: util.WriteResultToJSONFile(tests, result, options.isolated_script_test_output) sys.exit(len(result.failures) + len(result.errors))
def main(): usage = "usage: %prog <chromedriver binary> <chrome binary> [options]" parser = optparse.OptionParser(usage=usage) parser.add_option("", "--output-log-path", help="Output verbose server logs to this file") parser.add_option("", "--chrome-version", default="HEAD", help="Version of Chrome. Default is 'HEAD'.") parser.add_option( "", "--filter", type="string", default="*", help="Filter for specifying what tests to run, \"*\" will run all," "including tests excluded by default. E.g., *testRunMethod") parser.add_option("", "--devtools-replay", help="Replay DevTools instead of using\n" "real Chrome.") # Need global to access these from the test runner. # pylint: disable=global-variable-undefined global _OPTIONS, _CHROMEDRIVER, _CHROME # pylint: enable=global-variable-undefined _OPTIONS, args = parser.parse_args() _CHROMEDRIVER = util.GetAbsolutePathOfUserPath(args[0]) _CHROME = util.GetAbsolutePathOfUserPath(args[1]) if not os.path.exists(_CHROMEDRIVER): parser.error("Path given for chromedriver is invalid.\n" 'Please run "%s --help" for help' % __file__) if not os.path.exists(_CHROME): parser.error("Path given for chrome is invalid.\n" 'Please run "%s --help" for help' % __file__) all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( sys.modules[__name__]) test_filter = (GetNegativeFilter(_OPTIONS.chrome_version) if not _OPTIONS.filter else _OPTIONS.filter) tests = unittest_util.FilterTestSuite(all_tests_suite, test_filter) result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) sys.exit(len(result.failures) + len(result.errors))
global _REFERENCE_CHROMEDRIVER _REFERENCE_CHROMEDRIVER = util.GetAbsolutePathOfUserPath( options.reference_chromedriver) global _CHROME_BINARY if options.chrome: _CHROME_BINARY = util.GetAbsolutePathOfUserPath(options.chrome) else: _CHROME_BINARY = None global _ANDROID_PACKAGE_KEY _ANDROID_PACKAGE_KEY = options.android_package if options.filter == '*': if _ANDROID_PACKAGE_KEY: negative_filter = _ANDROID_NEGATIVE_FILTER[_ANDROID_PACKAGE_KEY] else: negative_filter = _GetDesktopNegativeFilter(options.chrome_version) options.filter = '*-' + ':__main__.'.join([''] + negative_filter) all_tests_suite = unittest.defaultTestLoader.loadTestsFromModule( sys.modules[__name__]) tests = unittest_util.FilterTestSuite(all_tests_suite, options.filter) ChromeDriverTest.GlobalSetUp() MobileEmulationCapabilityTest.GlobalSetUp() result = unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run(tests) ChromeDriverTest.GlobalTearDown() MobileEmulationCapabilityTest.GlobalTearDown() sys.exit(len(result.failures) + len(result.errors))