def main(): parser = optparse.OptionParser() parser.add_option( '', '--android-packages', help='Comma separated list of application package names, ' 'if running tests on Android.') # Option 'chrome-version' is for desktop only. parser.add_option( '', '--chrome-version', help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.' 'Default is to run tests against all of these versions.' 'Notice: this option only applies to desktop.') options, _ = parser.parse_args() exe_postfix = '' if util.IsWindows(): exe_postfix = '.exe' cpp_tests_name = 'chromedriver_tests' + exe_postfix server_name = 'chromedriver' + exe_postfix required_build_outputs = [server_name] if not options.android_packages: required_build_outputs += [cpp_tests_name] try: build_dir = chrome_paths.GetBuildDir(required_build_outputs) except RuntimeError: util.MarkBuildStepStart('check required binaries') traceback.print_exc() util.MarkBuildStepError() constants.SetBuildType(os.path.basename(build_dir)) print 'Using build outputs from', build_dir chromedriver = os.path.join(build_dir, server_name) platform_name = util.GetPlatformName() if util.IsLinux() and util.Is64Bit(): platform_name += '64' ref_chromedriver = os.path.join( chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests', 'reference_builds', 'chromedriver_%s%s' % (platform_name, exe_postfix)) if options.android_packages: os.environ['PATH'] += os.pathsep + os.path.join( _THIS_DIR, os.pardir, 'chrome') code = 0 for package in options.android_packages.split(','): code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome_version_name=package, android_package=package) code2 = RunJavaTests(chromedriver, chrome_version_name=package, android_package=package, verbose=True) code = code or code1 or code2 return code else: versions = {'HEAD': archive.GetLatestRevision()} code = 0 for version, revision in versions.iteritems(): if options.chrome_version and version != options.chrome_version: continue download_site = archive.GetDownloadSite() version_name = version if version_name == 'HEAD': version_name = revision temp_dir, chrome_path = DownloadChrome(version_name, revision, download_site) if not chrome_path: code = 1 continue code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code2 = RunJavaTests(chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name, verbose=True) code3 = RunReplayTests(chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code = code or code1 or code2 or code3 _KillChromes() shutil.rmtree(temp_dir) cpp_tests = os.path.join(build_dir, cpp_tests_name) return RunCppTests(cpp_tests) or code
import os import platform import shutil import sys import tempfile import traceback _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) _PARENT_DIR = os.path.join(_THIS_DIR, os.pardir) sys.path.insert(0, _PARENT_DIR) import archive import chrome_paths import util sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'android')) from pylib import constants def _GenerateTestCommand(script, chromedriver, ref_chromedriver=None, chrome=None, android_package=None, verbose=False): _, log_path = tempfile.mkstemp(prefix='chromedriver_log_') print 'chromedriver server log: %s' % log_path cmd = [ sys.executable, os.path.join(_THIS_DIR, script), '--chromedriver=%s' % chromedriver,
def main(): parser = optparse.OptionParser() parser.add_option('', '--verbose', action='store_true', default=False, help='Whether output should be verbose') parser.add_option('', '--debug', action='store_true', default=False, help='Whether to wait to be attached by a debugger') 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('', '--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('', '--android-package', help='Android package key') parser.add_option( '', '--filter', type='string', default=None, help='Filter for specifying what tests to run, "*" will run all. E.g., ' '*testShouldReturnTitleOfPageIfSet') parser.add_option('', '--also-run-disabled-tests', action='store_true', default=False, help='Include disabled tests while running the tests') parser.add_option('', '--isolate-tests', action='store_true', default=False, help='Relaunch the jar test harness after each test') options, _ = parser.parse_args() options.chromedriver = util.GetAbsolutePathOfUserPath(options.chromedriver) 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__) if options.android_package: if options.android_package not in constants.PACKAGE_INFO: parser.error('Invalid --android-package') if options.chrome_version != 'HEAD': parser.error( 'Android does not support the --chrome-version argument.') environment = test_environment.AndroidTestEnvironment( options.android_package) else: environment = test_environment.DesktopTestEnvironment( options.chrome_version) try: environment.GlobalSetUp() # Run passed tests when filter is not provided. if options.isolate_tests: test_filters = environment.GetPassedJavaTests() else: if options.filter: test_filter = options.filter else: test_filter = '*' if not options.also_run_disabled_tests: if '-' in test_filter: test_filter += ':' else: test_filter += '-' test_filter += ':'.join( environment.GetDisabledJavaTestMatchers()) test_filters = [test_filter] java_tests_src_dir = os.path.join(chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests') if (not os.path.exists(java_tests_src_dir) or not os.listdir(java_tests_src_dir)): java_tests_url = ('https://chromium.googlesource.com/chromium/deps' '/webdriver') print( '"%s" is empty or it doesn\'t exist. ' % java_tests_src_dir + 'Need to map ' + java_tests_url + ' to ' 'chrome/test/chromedriver/third_party/java_tests in .gclient.\n' 'Alternatively, do:\n' ' $ cd chrome/test/chromedriver/third_party\n' ' $ git clone %s java_tests' % java_tests_url) return 1 results = [] for filter in test_filters: results += _Run(java_tests_src_dir=java_tests_src_dir, test_filter=filter, chromedriver_path=options.chromedriver, chrome_path=util.GetAbsolutePathOfUserPath( options.chrome), log_path=options.log_path, android_package_key=options.android_package, verbose=options.verbose, debug=options.debug) return PrintTestResults(results) finally: environment.GlobalTearDown() if (os.path.exists(os.path.join(java_tests_src_dir, "build.xml"))): os.remove(os.path.join(java_tests_src_dir, "build.xml")) if (os.path.exists(os.path.join(java_tests_src_dir, "results.xml"))): os.remove(os.path.join(java_tests_src_dir, "results.xml")) if (os.path.exists( os.path.join(java_tests_src_dir, "chrome-wrapper-no-sandbox"))): os.remove( os.path.join(java_tests_src_dir, "chrome-wrapper-no-sandbox")) if (os.path.exists(os.path.join(java_tests_src_dir, "chrome-wrapper"))): os.remove(os.path.join(java_tests_src_dir, "chrome-wrapper"))
#!/usr/bin/env python # Copyright 2013 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. """Embeds Chrome user data files in C++ code.""" import optparse import os import re import sys import chrome_paths import cpp_source sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util')) import lastchange def main(): parser = optparse.OptionParser() parser.add_option('', '--version-file') parser.add_option( '', '--directory', type='string', default='.', help='Path to directory where the cc/h file should be created') options, _ = parser.parse_args() version = open(options.version_file, 'r').read().strip() revision = "undefined" if revision:
def main(): parser = optparse.OptionParser() parser.add_option('', '--version-file', type='string', default=os.path.join(chrome_paths.GetSrc(), 'chrome', 'VERSION'), help='Path to Chrome version file') parser.add_option( '', '--directory', type='string', default='.', help='Path to directory where the cc/h files should be created') options, args = parser.parse_args() # The device userAgent string may contain '%s', which should be replaced with # current Chrome version. First we read the version file. version_parts = ['MAJOR', 'MINOR', 'BUILD', 'PATCH'] version = [] version_file = open(options.version_file, 'r') for part in version_parts: # The version file should have 4 lines, with format like MAJOR=63 components = version_file.readline().split('=') if len(components) != 2 or components[0].strip() != part: print('Bad version file') return 1 version.append(components[1].strip()) # Join parts of version together using '.' as separator version = '.'.join(version) devices = {} file_name = args[0] inside_list = False with open(file_name, 'r') as f: emulated_devices = json.load(f) extensions = emulated_devices['extensions'] for extension in extensions: if extension['type'] == 'emulated-device': device = extension['device'] title = device['title'] titles = [title] # For 'iPhone 6/7/8', also add ['iPhone 6', 'iPhone 7', 'iPhone 8'] for # backward compatibility. if '/' in title: words = title.split() for i in range(len(words)): if '/' in words[i]: # Only support one word containing '/' break tokens = words[i].split('/') for token in tokens: words[i] = token titles.append(' '.join(words)) for title in titles: devices[title] = { 'userAgent': device['user-agent'].replace('%s', version), 'width': device['screen']['vertical']['width'], 'height': device['screen']['vertical']['height'], 'deviceScaleFactor': device['screen']['device-pixel-ratio'], 'touch': 'touch' in device['capabilities'], 'mobile': 'mobile' in device['capabilities'], } output_dir = 'chrome/test/chromedriver/chrome' cpp_source.WriteSource('mobile_device_list', output_dir, options.directory, {'kMobileDevices': json.dumps(devices)}) clang_format = ['clang-format', '-i'] subprocess.Popen(clang_format + ['%s/mobile_device_list.cc' % output_dir]) subprocess.Popen(clang_format + ['%s/mobile_device_list.h' % output_dir])
def main(): parser = optparse.OptionParser() parser.add_option( '', '--android-packages', help='Comma separated list of application package names, ' 'if running tests on Android.') # Option 'chrome-version' is for desktop only. parser.add_option( '', '--chrome-version', help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.' 'Default is to run tests against all of these versions.' 'Notice: this option only applies to desktop.') options, _ = parser.parse_args() exe_postfix = '' if util.IsWindows(): exe_postfix = '.exe' cpp_tests_name = 'chromedriver_tests' + exe_postfix server_name = 'chromedriver' + exe_postfix required_build_outputs = [server_name] if not options.android_packages: required_build_outputs += [cpp_tests_name] try: build_dir = chrome_paths.GetBuildDir(required_build_outputs) except RuntimeError: util.MarkBuildStepStart('check required binaries') traceback.print_exc() util.MarkBuildStepError() constants.SetBuildType(os.path.basename(build_dir)) print 'Using build outputs from', build_dir chromedriver = os.path.join(build_dir, server_name) platform_name = util.GetPlatformName() if util.IsLinux() and util.Is64Bit(): platform_name += '64' ref_chromedriver = os.path.join( chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests', 'reference_builds', 'chromedriver_%s%s' % (platform_name, exe_postfix)) if options.android_packages: os.environ['PATH'] += os.pathsep + os.path.join( _THIS_DIR, os.pardir, 'chrome') code = 0 for package in options.android_packages.split(','): code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome_version_name=package, android_package=package) code2 = RunJavaTests(chromedriver, chrome_version_name=package, android_package=package, verbose=True) code = code or code1 or code2 return code else: versions = {'HEAD': archive.GetLatestRevision()} if util.IsLinux() and not util.Is64Bit(): # Linux32 builds need to be special-cased, because 1) they are keyed by # git hash rather than commit position, and 2) come from a different # download site (so we can't just convert the commit position to a hash). versions['63'] = 'adb61db19020ed8ecee5e91b1a0ea4c924ae2988' versions['62'] = '17030e3a08cfbb6e591991f7dbf0eb703454b365' versions['61'] = '77132a2bc78e8dc9ce411e8166bfd009f6476f6f' # TODO(samuong): speculative fix for crbug.com/611886 os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox' # Linux64 build numbers elif util.IsLinux(): versions['66'] = '540276' versions['65'] = '530372' versions['64'] = '520842' # Mac build numbers elif util.IsMac(): versions['66'] = '540271' versions['65'] = '530368' versions['64'] = '520840' # Windows build numbers elif util.IsWindows(): versions['66'] = '540272' versions['65'] = '530366' versions['64'] = '520840' code = 0 for version, revision in versions.iteritems(): if options.chrome_version and version != options.chrome_version: continue download_site = archive.GetDownloadSite() version_name = version if version_name == 'HEAD': version_name = revision temp_dir, chrome_path = DownloadChrome(version_name, revision, download_site) if not chrome_path: code = 1 continue code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code2 = RunJavaTests(chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code = code or code1 or code2 _KillChromes() shutil.rmtree(temp_dir) cpp_tests = os.path.join(build_dir, cpp_tests_name) return RunCppTests(cpp_tests) or code
def main(): parser = optparse.OptionParser() parser.add_option( '', '--android-packages', help='Comma separated list of application package names, ' 'if running tests on Android.') # Option 'chrome-version' is for desktop only. parser.add_option( '', '--chrome-version', help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.' 'Default is to run tests against all of these versions.' 'Notice: this option only applies to desktop.') options, _ = parser.parse_args() exe_postfix = '' if util.IsWindows(): exe_postfix = '.exe' cpp_tests_name = 'chromedriver_tests' + exe_postfix server_name = 'chromedriver' + exe_postfix required_build_outputs = [server_name] if not options.android_packages: required_build_outputs += [cpp_tests_name] build_dir = chrome_paths.GetBuildDir(required_build_outputs) constants.SetBuildType(os.path.basename(build_dir)) print 'Using build outputs from', build_dir chromedriver = os.path.join(build_dir, server_name) platform_name = util.GetPlatformName() if util.IsLinux() and platform.architecture()[0] == '64bit': platform_name += '64' ref_chromedriver = os.path.join( chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests', 'reference_builds', 'chromedriver_%s%s' % (platform_name, exe_postfix)) if options.android_packages: os.environ['PATH'] += os.pathsep + os.path.join( _THIS_DIR, os.pardir, 'chrome') code = 0 for package in options.android_packages.split(','): code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome_version_name=package, android_package=package) code2 = RunJavaTests(chromedriver, chrome_version_name=package, android_package=package, verbose=True) code = code or code1 or code2 return code else: latest_snapshot_revision = archive.GetLatestRevision(archive.Site.SNAPSHOT) versions = [ ['HEAD', latest_snapshot_revision], ['32', archive.CHROME_32_REVISION], ['31', archive.CHROME_31_REVISION], ['30', archive.CHROME_30_REVISION] ] code = 0 for version in versions: if options.chrome_version and version[0] != options.chrome_version: continue download_site = archive.Site.CONTINUOUS version_name = version[0] if version_name == 'HEAD': version_name = version[1] download_site = archive.Site.SNAPSHOT chrome_path = DownloadChrome(version_name, version[1], download_site) code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome=chrome_path, chrome_version=version[0], chrome_version_name='v%s' % version_name) code2 = RunJavaTests(chromedriver, chrome=chrome_path, chrome_version=version[0], chrome_version_name='v%s' % version_name) code = code or code1 or code2 cpp_tests = os.path.join(build_dir, cpp_tests_name) return RunCppTests(cpp_tests) or code
tests in various environments. """ import logging import os import sys import chrome_paths import util _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) if util.IsLinux(): sys.path.insert( 0, os.path.join(chrome_paths.GetSrc(), 'third_party', 'catapult', 'devil')) from devil.android import device_errors from devil.android import device_utils from devil.android import forwarder sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'android')) import devil_chromium ANDROID_TEST_HTTP_PORT = 2311 ANDROID_TEST_HTTPS_PORT = 2411 _EXPECTATIONS = {} execfile(os.path.join(_THIS_DIR, 'test_expectations'), _EXPECTATIONS)
def main(): parser = optparse.OptionParser() parser.add_option( '', '--android-packages', help='Comma separated list of application package names, ' 'if running tests on Android.') # Option 'chrome-version' is for desktop only. parser.add_option( '', '--chrome-version', help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.' 'Default is to run tests against all of these versions.' 'Notice: this option only applies to desktop.') options, _ = parser.parse_args() exe_postfix = '' if util.IsWindows(): exe_postfix = '.exe' cpp_tests_name = 'chromedriver_tests' + exe_postfix server_name = 'chromedriver' + exe_postfix required_build_outputs = [server_name] if not options.android_packages: required_build_outputs += [cpp_tests_name] try: build_dir = chrome_paths.GetBuildDir(required_build_outputs) except RuntimeError: util.MarkBuildStepStart('check required binaries') traceback.print_exc() util.MarkBuildStepError() constants.SetBuildType(os.path.basename(build_dir)) print 'Using build outputs from', build_dir chromedriver = os.path.join(build_dir, server_name) platform_name = util.GetPlatformName() if util.IsLinux() and util.Is64Bit(): platform_name += '64' ref_chromedriver = os.path.join( chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests', 'reference_builds', 'chromedriver_%s%s' % (platform_name, exe_postfix)) if options.android_packages: os.environ['PATH'] += os.pathsep + os.path.join( _THIS_DIR, os.pardir, 'chrome') code = 0 for package in options.android_packages.split(','): code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome_version_name=package, android_package=package) code2 = RunJavaTests(chromedriver, chrome_version_name=package, android_package=package, verbose=True) code = code or code1 or code2 return code else: versions = {'HEAD': archive.GetLatestRevision()} if util.IsLinux() and not util.Is64Bit(): # Linux32 builds need to be special-cased, because 1) they are keyed by # git hash rather than commit position, and 2) come from a different # download site (so we can't just convert the commit position to a hash). versions['60'] = 'c1148176d6794fff0fd8dba2b9f7ed71ec52fed8' versions['59'] = 'c407e95a371a94bfd714e25eab788c9405de6975' versions['58'] = '7613176285d46fbc5b4712e42bd135aae99cbba5' # TODO(samuong): speculative fix for crbug.com/611886 os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox' else: versions['60'] = '474969' versions['59'] = '464674' versions['58'] = '454475' code = 0 for version, revision in versions.iteritems(): if options.chrome_version and version != options.chrome_version: continue download_site = archive.GetDownloadSite() version_name = version if version_name == 'HEAD': version_name = revision temp_dir, chrome_path = DownloadChrome(version_name, revision, download_site) if not chrome_path: code = 1 continue code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code2 = RunJavaTests(chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code = code or code1 or code2 _KillChromes() shutil.rmtree(temp_dir) cpp_tests = os.path.join(build_dir, cpp_tests_name) return RunCppTests(cpp_tests) or code
# Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import os import sys import json from command_executor import CommandExecutor _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) _PARENT_DIR = os.path.join(_THIS_DIR, os.pardir) sys.path.insert(1, _PARENT_DIR) import chrome_paths sys.path.remove(_PARENT_DIR) sys.path.insert( 0, os.path.join(chrome_paths.GetSrc(), 'third_party', 'catapult', 'telemetry', 'third_party', 'websocket-client')) import websocket class WebSocketCommands: CREATE_WEBSOCKET = \ '/session/:sessionId/chromium/create_websocket' SEND_OVER_WEBSOCKET = \ '/session/:sessionId/chromium/send_command_from_websocket' class WebSocketConnection(object): def __init__(self, server_url, session_id): self._server_url = server_url.replace('http', 'ws') self._session_id = session_id
def main(): parser = optparse.OptionParser() parser.add_option( '', '--android-package', help='Application package name, if running tests on Android.') # Option 'chrome-version' is for desktop only. parser.add_option( '', '--chrome-version', help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.' 'Default is to run tests against all of these versions.' 'Notice: this option only applies to desktop.') options, _ = parser.parse_args() exe_postfix = '' if util.IsWindows(): exe_postfix = '.exe' cpp_tests_name = 'chromedriver2_tests' + exe_postfix server_name = 'chromedriver2_server' + exe_postfix required_build_outputs = [server_name] if not options.android_package: required_build_outputs += [cpp_tests_name] build_dir = chrome_paths.GetBuildDir(required_build_outputs) print 'Using build outputs from', build_dir chromedriver = os.path.join(build_dir, server_name) platform_name = util.GetPlatformName() if util.IsLinux() and platform.architecture()[0] == '64bit': platform_name += '64' ref_chromedriver = os.path.join( chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests', 'reference_builds', 'chromedriver_%s%s' % (platform_name, exe_postfix)) if util.IsLinux(): # Set LD_LIBRARY_PATH to enable successful loading of shared object files, # when chromedriver2.so is not a static build. _AppendEnvironmentPath('LD_LIBRARY_PATH', os.path.join(build_dir, 'lib')) elif util.IsWindows(): # For Windows bots: add ant, java(jre) and the like to system path. _AddToolsToSystemPathForWindows() if options.android_package: os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome') code1 = RunPythonTests(chromedriver, ref_chromedriver, android_package=options.android_package) code2 = RunJavaTests(chromedriver, android_package=options.android_package) return code1 or code2 else: latest_snapshot_revision = archive.GetLatestRevision( archive.Site.SNAPSHOT) versions = [['HEAD', latest_snapshot_revision], ['29', archive.CHROME_29_REVISION], ['28', archive.CHROME_28_REVISION], ['27', archive.CHROME_27_REVISION]] code = 0 for version in versions: if options.chrome_version and version[0] != options.chrome_version: continue download_site = archive.Site.CONTINUOUS version_name = version[0] if version_name == 'HEAD': version_name = version[1] download_site = archive.Site.SNAPSHOT chrome_path = DownloadChrome(version_name, version[1], download_site) code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome=chrome_path, chrome_version=version[0], chrome_version_name=version_name) code2 = RunJavaTests(chromedriver, chrome=chrome_path, chrome_version=version[0], chrome_version_name=version_name) code = code or code1 or code2 cpp_tests = os.path.join(build_dir, cpp_tests_name) return RunCppTests(cpp_tests) or code
def main(): parser = optparse.OptionParser() parser.add_option('', '--verbose', action='store_true', default=False, help='Whether output should be verbose') parser.add_option('', '--debug', action='store_true', default=False, help='Whether to wait to be attached by a debugger') 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('', '--chrome-version', default='HEAD', help='Version of chrome. Default is \'HEAD\'') parser.add_option('', '--android-package', type='string', default=None, help='Name of Chrome\'s Android package') parser.add_option( '', '--filter', type='string', default=None, help='Filter for specifying what tests to run, "*" will run all. E.g., ' '*testShouldReturnTitleOfPageIfSet') parser.add_option('', '--also-run-disabled-tests', action='store_true', default=False, help='Include disabled tests while running the tests') parser.add_option('', '--isolate-tests', action='store_true', default=False, help='Relaunch the jar test harness after each test') options, _ = 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__) if options.android_package is not None: if options.chrome_version != 'HEAD': parser.error( 'Android does not support the --chrome-version argument.') environment = test_environment.AndroidTestEnvironment() else: environment = test_environment.DesktopTestEnvironment( options.chrome_version) try: environment.GlobalSetUp() # Run passed tests when filter is not provided. if options.isolate_tests: test_filters = environment.GetPassedJavaTests() else: if options.filter: test_filter = options.filter else: test_filter = '*' if not options.also_run_disabled_tests: if '-' in test_filter: test_filter += ':' else: test_filter += '-' test_filter += ':'.join( environment.GetDisabledJavaTestMatchers()) test_filters = [test_filter] java_tests_src_dir = os.path.join(chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests') if (not os.path.exists(java_tests_src_dir) or not os.listdir(java_tests_src_dir)): print( '"%s" is empty or it doesn\'t exist.' % java_tests_src_dir + 'Should add deps/third_party/webdriver to source checkout config' ) return 1 results = [] for filter in test_filters: results += _Run(java_tests_src_dir=java_tests_src_dir, test_filter=filter, chromedriver_path=options.chromedriver, chrome_path=options.chrome, android_package=options.android_package, verbose=options.verbose, debug=options.debug) return PrintTestResults(results) finally: environment.GlobalTearDown()
def main(): parser = optparse.OptionParser() parser.add_option( '', '--android-packages', help='Comma separated list of application package names, ' 'if running tests on Android.') # Option 'chrome-version' is for desktop only. parser.add_option( '', '--chrome-version', help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.' 'Default is to run tests against all of these versions.' 'Notice: this option only applies to desktop.') options, _ = parser.parse_args() exe_postfix = '' if util.IsWindows(): exe_postfix = '.exe' cpp_tests_name = 'chromedriver_tests' + exe_postfix server_name = 'chromedriver' + exe_postfix required_build_outputs = [server_name] if not options.android_packages: required_build_outputs += [cpp_tests_name] try: build_dir = chrome_paths.GetBuildDir(required_build_outputs) except RuntimeError: util.MarkBuildStepStart('check required binaries') traceback.print_exc() util.MarkBuildStepError() constants.SetBuildType(os.path.basename(build_dir)) print 'Using build outputs from', build_dir chromedriver = os.path.join(build_dir, server_name) platform_name = util.GetPlatformName() if util.IsLinux() and util.Is64Bit(): platform_name += '64' ref_chromedriver = os.path.join( chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests', 'reference_builds', 'chromedriver_%s%s' % (platform_name, exe_postfix)) if options.android_packages: os.environ['PATH'] += os.pathsep + os.path.join( _THIS_DIR, os.pardir, 'chrome') code = 0 for package in options.android_packages.split(','): code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome_version_name=package, android_package=package) code2 = RunJavaTests(chromedriver, chrome_version_name=package, android_package=package, verbose=True) code = code or code1 or code2 return code else: versions = {'HEAD': archive.GetLatestRevision()} if util.IsLinux() and not util.Is64Bit(): # Linux32 builds need to be special-cased, because 1) they are keyed by # git hash rather than commit position, and 2) come from a different # download site (so we can't just convert the commit position to a hash). versions['57'] = '7da9cd89d4d18e171323ff7d0d2a93ede0c1d721' versions['56'] = '67002b0fdaa3123f10f96fa2f7965677d531db74' versions['55'] = 'e9bc4e0245c9a1e570ed2cf8e12152b9122275f2' # TODO(samuong): speculative fix for crbug.com/611886 os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox' else: versions['57'] = '444890' versions['56'] = '433020' versions['55'] = '423791' code = 0 for version, revision in versions.iteritems(): if options.chrome_version and version != options.chrome_version: continue download_site = archive.GetDownloadSite() version_name = version if version_name == 'HEAD': version_name = revision temp_dir, chrome_path = DownloadChrome(version_name, revision, download_site) if not chrome_path: code = 1 continue code1 = RunPythonTests(chromedriver, ref_chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code2 = RunJavaTests(chromedriver, chrome=chrome_path, chrome_version=version, chrome_version_name='v%s' % version_name) code = code or code1 or code2 _KillChromes() shutil.rmtree(temp_dir) cpp_tests = os.path.join(build_dir, cpp_tests_name) return RunCppTests(cpp_tests) or code