OLD | NEW |
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 the WebDriver Java acceptance tests. | 6 """Runs the WebDriver Java acceptance tests. |
7 | 7 |
8 This script is called from chrome/test/chromedriver/run_all_tests.py and reports | 8 This script is called from chrome/test/chromedriver/run_all_tests.py and reports |
9 results using the buildbot annotation scheme. | 9 results using the buildbot annotation scheme. |
10 | 10 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 print '=' * 10, result.GetName(), '(%ss)' % result.GetTime() | 208 print '=' * 10, result.GetName(), '(%ss)' % result.GetTime() |
209 print result.GetFailureMessage() | 209 print result.GetFailureMessage() |
210 if len(failures) > 0: | 210 if len(failures) > 0: |
211 print '@@@STEP_TEXT@Failed %s tests@@@' % len(failures) | 211 print '@@@STEP_TEXT@Failed %s tests@@@' % len(failures) |
212 return len(failures) | 212 return len(failures) |
213 | 213 |
214 | 214 |
215 def main(): | 215 def main(): |
216 parser = optparse.OptionParser() | 216 parser = optparse.OptionParser() |
217 parser.add_option( | 217 parser.add_option( |
218 '', '--chromedriver_path', type='string', default=None, | 218 '', '--chromedriver', type='string', default=None, |
219 help='Path to a build of the chromedriver library(REQUIRED!)') | 219 help='Path to a build of the chromedriver library(REQUIRED!)') |
220 parser.add_option( | 220 parser.add_option( |
221 '', '--chrome_path', type='string', default=None, | 221 '', '--chrome', type='string', default=None, |
222 help='Path to a build of the chrome binary') | 222 help='Path to a build of the chrome binary') |
223 parser.add_option( | 223 parser.add_option( |
224 '', '--filter', type='string', default=None, | 224 '', '--filter', type='string', default=None, |
225 help='Filter for specifying what tests to run, "*" will run all. E.g., ' + | 225 help='Filter for specifying what tests to run, "*" will run all. E.g., ' + |
226 'AppCacheTest,ElementFindingTest#testShouldReturnTitleOfPageIfSet.') | 226 'AppCacheTest,ElementFindingTest#testShouldReturnTitleOfPageIfSet.') |
227 options, args = parser.parse_args() | 227 options, args = parser.parse_args() |
228 | 228 |
229 if (options.chromedriver_path is None or | 229 if (options.chromedriver is None or not os.path.exists(options.chromedriver)): |
230 not os.path.exists(options.chromedriver_path)): | 230 parser.error('chromedriver is required or the given path is invalid.' + |
231 parser.error('chromedriver_path is required or the given path is invalid.' + | |
232 'Please run "%s --help" for help' % __file__) | 231 'Please run "%s --help" for help' % __file__) |
233 | 232 |
234 # Run passed tests when filter is not provided. | 233 # Run passed tests when filter is not provided. |
235 test_filter = options.filter | 234 test_filter = options.filter |
236 if test_filter is None: | 235 if test_filter is None: |
237 passed_java_tests_file = open( | 236 passed_java_tests_file = open( |
238 os.path.join(_THIS_DIR, 'passed_java_tests.txt')) | 237 os.path.join(_THIS_DIR, 'passed_java_tests.txt')) |
239 passed_java_tests = [line.strip('\n') for line in passed_java_tests_file] | 238 passed_java_tests = [line.strip('\n') for line in passed_java_tests_file] |
240 passed_java_tests_file.close() | 239 passed_java_tests_file.close() |
241 test_filter = ','.join(passed_java_tests) | 240 test_filter = ','.join(passed_java_tests) |
242 | 241 |
243 java_tests_src_dir = os.path.join(chrome_paths.GetSrc(), 'chrome', 'test', | 242 java_tests_src_dir = os.path.join(chrome_paths.GetSrc(), 'chrome', 'test', |
244 'chromedriver', 'third_party', 'java_tests') | 243 'chromedriver', 'third_party', 'java_tests') |
245 if (not os.path.exists(java_tests_src_dir) or | 244 if (not os.path.exists(java_tests_src_dir) or |
246 not os.listdir(java_tests_src_dir)): | 245 not os.listdir(java_tests_src_dir)): |
247 print ('"%s" is empty or it doesn\'t exist.' % java_tests_src_dir + | 246 print ('"%s" is empty or it doesn\'t exist.' % java_tests_src_dir + |
248 'Should add "deps/third_party/webdriver" to source checkout config') | 247 'Should add "deps/third_party/webdriver" to source checkout config') |
249 return 1; | 248 return 1; |
250 | 249 |
251 return PrintTestResults(_Run( | 250 return PrintTestResults(_Run( |
252 src_dir=chrome_paths.GetSrc(), | 251 src_dir=chrome_paths.GetSrc(), |
253 java_tests_src_dir=java_tests_src_dir, | 252 java_tests_src_dir=java_tests_src_dir, |
254 test_filter=test_filter, | 253 test_filter=test_filter, |
255 chromedriver_path=options.chromedriver_path, | 254 chromedriver_path=options.chromedriver, |
256 chrome_path=options.chrome_path)) | 255 chrome_path=options.chrome)) |
257 | 256 |
258 | 257 |
259 if __name__ == '__main__': | 258 if __name__ == '__main__': |
260 sys.exit(main()) | 259 sys.exit(main()) |
OLD | NEW |