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

Side by Side Diff: chrome/test/chromedriver/run_all_tests.py

Issue 15979030: [chromedriver] Add some simple perf benchmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/chromedriver/run_py_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs all ChromeDriver end to end tests.""" 6 """Runs all ChromeDriver end to end tests."""
7 7
8 import optparse 8 import optparse
9 import os 9 import os
10 import sys 10 import sys
(...skipping 16 matching lines...) Expand all
27 27
28 def _AddToolsToSystemPathForWindows(): 28 def _AddToolsToSystemPathForWindows():
29 path_cfg_file = 'C:\\tools\\bots_path.cfg' 29 path_cfg_file = 'C:\\tools\\bots_path.cfg'
30 if not os.path.exists(path_cfg_file): 30 if not os.path.exists(path_cfg_file):
31 print 'Failed to find file', path_cfg_file 31 print 'Failed to find file', path_cfg_file
32 with open(path_cfg_file, 'r') as cfg: 32 with open(path_cfg_file, 'r') as cfg:
33 paths = cfg.read().split('\n') 33 paths = cfg.read().split('\n')
34 os.environ['PATH'] = os.pathsep.join(paths) + os.pathsep + os.environ['PATH'] 34 os.environ['PATH'] = os.pathsep.join(paths) + os.pathsep + os.environ['PATH']
35 35
36 36
37 def _GenerateTestCommand(script, chromedriver, chrome=None, 37 def _GenerateTestCommand(script,
38 chrome_version=None, android_package=None): 38 chromedriver,
39 ref_chromedriver=None,
40 chrome=None,
41 chrome_version=None,
42 android_package=None):
39 cmd = [ 43 cmd = [
40 sys.executable, 44 sys.executable,
41 os.path.join(_THIS_DIR, script), 45 os.path.join(_THIS_DIR, script),
42 '--chromedriver=' + chromedriver, 46 '--chromedriver=' + chromedriver,
43 ] 47 ]
48 if ref_chromedriver:
49 cmd.append('--reference-chromedriver=' + ref_chromedriver)
44 if chrome: 50 if chrome:
45 cmd.append('--chrome=' + chrome) 51 cmd.append('--chrome=' + chrome)
46 if chrome_version: 52 if chrome_version:
47 cmd.append('--chrome-version=' + chrome_version) 53 cmd.append('--chrome-version=' + chrome_version)
48 54
49 if android_package: 55 if android_package:
50 cmd.append('--android-package=' + android_package) 56 cmd.append('--android-package=' + android_package)
51 return cmd 57 return cmd
52 58
53 59
54 def RunPythonTests(chromedriver, chrome=None, chrome_version=None, 60 def RunPythonTests(chromedriver, ref_chromedriver,
61 chrome=None, chrome_version=None,
55 chrome_version_name=None, android_package=None): 62 chrome_version_name=None, android_package=None):
56 version_info = '' 63 version_info = ''
57 if chrome_version_name: 64 if chrome_version_name:
58 version_info = '(v%s)' % chrome_version_name 65 version_info = '(v%s)' % chrome_version_name
59 util.MarkBuildStepStart('python_tests%s' % version_info) 66 util.MarkBuildStepStart('python_tests%s' % version_info)
60 code = util.RunCommand( 67 code = util.RunCommand(
61 _GenerateTestCommand('run_py_tests.py', chromedriver, chrome, 68 _GenerateTestCommand('run_py_tests.py',
62 chrome_version, android_package)) 69 chromedriver,
70 ref_chromedriver=ref_chromedriver,
71 chrome=chrome,
72 chrome_version=chrome_version,
73 android_package=android_package))
63 if code: 74 if code:
64 util.MarkBuildStepError() 75 util.MarkBuildStepError()
65 return code 76 return code
66 77
67 78
68 def RunJavaTests(chromedriver, chrome=None, chrome_version=None, 79 def RunJavaTests(chromedriver, chrome=None, chrome_version=None,
69 chrome_version_name=None, android_package=None): 80 chrome_version_name=None, android_package=None):
70 version_info = '' 81 version_info = ''
71 if chrome_version_name: 82 if chrome_version_name:
72 version_info = '(v%s)' % chrome_version_name 83 version_info = '(v%s)' % chrome_version_name
73 util.MarkBuildStepStart('java_tests%s' % version_info) 84 util.MarkBuildStepStart('java_tests%s' % version_info)
74 code = util.RunCommand( 85 code = util.RunCommand(
75 _GenerateTestCommand('run_java_tests.py', chromedriver, chrome, 86 _GenerateTestCommand('run_java_tests.py',
76 chrome_version, android_package)) 87 chromedriver,
88 ref_chromedriver=None,
89 chrome=chrome,
90 chrome_version=chrome_version,
91 android_package=android_package))
77 if code: 92 if code:
78 util.MarkBuildStepError() 93 util.MarkBuildStepError()
79 return code 94 return code
80 95
81 96
82 def RunCppTests(cpp_tests): 97 def RunCppTests(cpp_tests):
83 util.MarkBuildStepStart('chromedriver2_tests') 98 util.MarkBuildStepStart('chromedriver2_tests')
84 code = util.RunCommand([cpp_tests]) 99 code = util.RunCommand([cpp_tests])
85 if code: 100 if code:
86 util.MarkBuildStepError() 101 util.MarkBuildStepError()
87 return code 102 return code
88 103
89 104
90 def main(): 105 def main():
91 parser = optparse.OptionParser() 106 parser = optparse.OptionParser()
92 parser.add_option( 107 parser.add_option(
93 '', '--android-package', 108 '', '--android-package',
94 help='Application package name, if running tests on Android.') 109 help='Application package name, if running tests on Android.')
95 # Option 'chrome-version' is for desktop only. 110 # Option 'chrome-version' is for desktop only.
96 parser.add_option( 111 parser.add_option(
97 '', '--chrome-version', 112 '', '--chrome-version',
98 help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.' 113 help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
99 'Default is to run tests against all of these versions.' 114 'Default is to run tests against all of these versions.'
100 'Notice: this option only applies to desktop.') 115 'Notice: this option only applies to desktop.')
101 options, _ = parser.parse_args() 116 options, _ = parser.parse_args()
102 117
103 postfix = '' 118 exe_postfix = ''
104 if util.IsWindows(): 119 if util.IsWindows():
105 postfix = '.exe' 120 exe_postfix = '.exe'
106 cpp_tests_name = 'chromedriver2_tests' + postfix 121 cpp_tests_name = 'chromedriver2_tests' + exe_postfix
107 server_name = 'chromedriver2_server' + postfix 122 server_name = 'chromedriver2_server' + exe_postfix
108 123
109 required_build_outputs = [server_name] 124 required_build_outputs = [server_name]
110 if not options.android_package: 125 if not options.android_package:
111 required_build_outputs += [cpp_tests_name] 126 required_build_outputs += [cpp_tests_name]
112 build_dir = chrome_paths.GetBuildDir(required_build_outputs) 127 build_dir = chrome_paths.GetBuildDir(required_build_outputs)
113 print 'Using build outputs from', build_dir 128 print 'Using build outputs from', build_dir
114 129
115 chromedriver_server = os.path.join(build_dir, server_name) 130 chromedriver = os.path.join(build_dir, server_name)
131 ref_chromedriver = os.path.join(
132 chrome_paths.GetSrc(),
133 'chrome', 'test', 'chromedriver', 'third_party', 'java_tests',
134 'reference_builds',
135 'chromedriver_%s%s' % (util.GetPlatformName(), exe_postfix))
116 136
117 if util.IsLinux(): 137 if util.IsLinux():
118 # Set LD_LIBRARY_PATH to enable successful loading of shared object files, 138 # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
119 # when chromedriver2.so is not a static build. 139 # when chromedriver2.so is not a static build.
120 _AppendEnvironmentPath('LD_LIBRARY_PATH', os.path.join(build_dir, 'lib')) 140 _AppendEnvironmentPath('LD_LIBRARY_PATH', os.path.join(build_dir, 'lib'))
121 elif util.IsWindows(): 141 elif util.IsWindows():
122 # For Windows bots: add ant, java(jre) and the like to system path. 142 # For Windows bots: add ant, java(jre) and the like to system path.
123 _AddToolsToSystemPathForWindows() 143 _AddToolsToSystemPathForWindows()
124 144
125 if options.android_package: 145 if options.android_package:
126 os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome') 146 os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome')
127 code1 = RunPythonTests(chromedriver_server, 147 code1 = RunPythonTests(chromedriver,
148 ref_chromedriver,
128 android_package=options.android_package) 149 android_package=options.android_package)
129 code2 = RunJavaTests(chromedriver_server, 150 code2 = RunJavaTests(chromedriver,
130 android_package=options.android_package) 151 android_package=options.android_package)
131 return code1 or code2 152 return code1 or code2
132 else: 153 else:
133 latest_snapshot_revision = archive.GetLatestRevision(archive.Site.SNAPSHOT) 154 latest_snapshot_revision = archive.GetLatestRevision(archive.Site.SNAPSHOT)
134 versions = [ 155 versions = [
135 ['HEAD', latest_snapshot_revision], 156 ['HEAD', latest_snapshot_revision],
136 ['28', archive.CHROME_28_REVISION], 157 ['28', archive.CHROME_28_REVISION],
137 ['27', archive.CHROME_27_REVISION] 158 ['27', archive.CHROME_27_REVISION]
138 ] 159 ]
139 code = 0 160 code = 0
140 for version in versions: 161 for version in versions:
141 if options.chrome_version and version[0] != options.chrome_version: 162 if options.chrome_version and version[0] != options.chrome_version:
142 continue 163 continue
143 download_site = archive.Site.CONTINUOUS 164 download_site = archive.Site.CONTINUOUS
144 version_name = version[0] 165 version_name = version[0]
145 if version_name == 'HEAD': 166 if version_name == 'HEAD':
146 version_name = version[1] 167 version_name = version[1]
147 download_site = archive.Site.SNAPSHOT 168 download_site = archive.Site.SNAPSHOT
148 chrome_path = archive.DownloadChrome(version[1], 169 chrome_path = archive.DownloadChrome(version[1],
149 util.MakeTempDir(), 170 util.MakeTempDir(),
150 download_site) 171 download_site)
151 code1 = RunPythonTests(chromedriver_server, chrome=chrome_path, 172 code1 = RunPythonTests(chromedriver,
173 ref_chromedriver,
174 chrome=chrome_path,
152 chrome_version=version[0], 175 chrome_version=version[0],
153 chrome_version_name=version_name) 176 chrome_version_name=version_name)
154 code2 = RunJavaTests(chromedriver_server, chrome=chrome_path, 177 code2 = RunJavaTests(chromedriver, chrome=chrome_path,
155 chrome_version=version[0], 178 chrome_version=version[0],
156 chrome_version_name=version_name) 179 chrome_version_name=version_name)
157 code = code or code1 or code2 180 code = code or code1 or code2
158 cpp_tests = os.path.join(build_dir, cpp_tests_name) 181 cpp_tests = os.path.join(build_dir, cpp_tests_name)
159 return RunCppTests(cpp_tests) or code 182 return RunCppTests(cpp_tests) or code
160 183
161 184
162 if __name__ == '__main__': 185 if __name__ == '__main__':
163 sys.exit(main()) 186 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | chrome/test/chromedriver/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698