OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 import optparse | 6 import argparse |
7 import os | 7 import os |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import time | 10 import time |
11 | 11 |
12 import build_projects | 12 import build_projects |
13 import build_version | 13 import build_version |
14 import buildbot_common | 14 import buildbot_common |
15 import parse_dsc | 15 import parse_dsc |
16 | 16 |
17 from build_paths import OUT_DIR, SRC_DIR, SDK_SRC_DIR, SCRIPT_DIR | 17 from build_paths import OUT_DIR, SRC_DIR, SDK_SRC_DIR, SCRIPT_DIR |
18 | 18 |
19 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) | 19 sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) |
20 import getos | 20 import getos |
21 platform = getos.GetPlatform() | 21 platform = getos.GetPlatform() |
22 | 22 |
23 # TODO(binji): ugly hack -- can I get the browser in a cleaner way? | 23 # TODO(binji): ugly hack -- can I get the browser in a cleaner way? |
24 sys.path.append(os.path.join(SRC_DIR, 'chrome', 'test', 'nacl_test_injection')) | 24 sys.path.append(os.path.join(SRC_DIR, 'chrome', 'test', 'nacl_test_injection')) |
25 import find_chrome | 25 import find_chrome |
26 browser_path = find_chrome.FindChrome(SRC_DIR, ['Debug', 'Release']) | 26 browser_path = find_chrome.FindChrome(SRC_DIR, ['Debug', 'Release']) |
27 | 27 |
28 # Fall back to using CHROME_PATH (same as in common.mk) | 28 # Fall back to using CHROME_PATH (same as in common.mk) |
29 if not browser_path: | 29 if not browser_path: |
30 browser_path = os.environ['CHROME_PATH'] | 30 browser_path = os.environ.get('CHROME_PATH') |
31 | 31 |
32 | 32 |
33 pepper_ver = str(int(build_version.ChromeMajorVersion())) | 33 pepper_ver = str(int(build_version.ChromeMajorVersion())) |
34 pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) | 34 pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) |
35 | 35 |
36 browser_tester_py = os.path.join(SRC_DIR, 'ppapi', 'native_client', 'tools', | 36 browser_tester_py = os.path.join(SRC_DIR, 'ppapi', 'native_client', 'tools', |
37 'browser_tester', 'browser_tester.py') | 37 'browser_tester', 'browser_tester.py') |
38 | 38 |
39 | 39 |
40 ALL_CONFIGS = ['Debug', 'Release'] | 40 ALL_CONFIGS = ['Debug', 'Release'] |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 # Everything in src is a library, and cannot be run. | 306 # Everything in src is a library, and cannot be run. |
307 exclude = {'DEST': 'src'} | 307 exclude = {'DEST': 'src'} |
308 try: | 308 try: |
309 return parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=include, | 309 return parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=include, |
310 exclude=exclude) | 310 exclude=exclude) |
311 except parse_dsc.ValidationError as e: | 311 except parse_dsc.ValidationError as e: |
312 buildbot_common.ErrorExit(str(e)) | 312 buildbot_common.ErrorExit(str(e)) |
313 | 313 |
314 | 314 |
315 def main(args): | 315 def main(args): |
316 parser = optparse.OptionParser() | 316 parser = argparse.ArgumentParser(description=__doc__) |
317 parser.add_option('-c', '--config', | 317 parser.add_argument('-c', '--config', |
318 help='Choose configuration to run (Debug or Release). Runs both ' | 318 help='Choose configuration to run (Debug or Release). Runs both ' |
319 'by default', action='append') | 319 'by default', action='append') |
320 parser.add_option('-x', '--experimental', | 320 parser.add_argument('-x', '--experimental', |
321 help='Run experimental projects', action='store_true') | 321 help='Run experimental projects', action='store_true') |
322 parser.add_option('-t', '--toolchain', | 322 parser.add_argument('-t', '--toolchain', |
323 help='Run using toolchain. Can be passed more than once.', | 323 help='Run using toolchain. Can be passed more than once.', |
324 action='append', default=[]) | 324 action='append', default=[]) |
325 parser.add_option('-d', '--dest', | 325 parser.add_argument('-d', '--dest', |
326 help='Select which destinations (project types) are valid.', | 326 help='Select which destinations (project types) are valid.', |
327 action='append') | 327 action='append') |
328 parser.add_option('-b', '--build', | 328 parser.add_argument('-b', '--build', |
329 help='Build each project before testing.', action='store_true') | 329 help='Build each project before testing.', action='store_true') |
330 parser.add_option('--retry-times', | 330 parser.add_argument('--retry-times', |
331 help='Number of types to retry on failure (Default: %default)', | 331 help='Number of types to retry on failure (Default: %default)', |
332 type='int', default=1) | 332 type=int, default=1) |
| 333 parser.add_argument('projects', nargs='*') |
333 | 334 |
334 options, args = parser.parse_args(args) | 335 options = parser.parse_args(args) |
335 | 336 |
336 if not options.toolchain: | 337 if not options.toolchain: |
337 options.toolchain = ['newlib', 'glibc', 'pnacl', 'host'] | 338 options.toolchain = ['newlib', 'glibc', 'pnacl', 'host'] |
338 | 339 |
339 if 'host' in options.toolchain: | 340 if 'host' in options.toolchain: |
340 options.toolchain.remove('host') | 341 options.toolchain.remove('host') |
341 options.toolchain.append(platform) | 342 options.toolchain.append(platform) |
342 print 'Adding platform: ' + platform | 343 print 'Adding platform: ' + platform |
343 | 344 |
344 ValidateToolchains(options.toolchain) | 345 ValidateToolchains(options.toolchain) |
345 | 346 |
346 include = {} | 347 include = {} |
347 if options.toolchain: | 348 if options.toolchain: |
348 include['TOOLS'] = options.toolchain | 349 include['TOOLS'] = options.toolchain |
349 print 'Filter by toolchain: ' + str(options.toolchain) | 350 print 'Filter by toolchain: ' + str(options.toolchain) |
350 if not options.experimental: | 351 if not options.experimental: |
351 include['EXPERIMENTAL'] = False | 352 include['EXPERIMENTAL'] = False |
352 if options.dest: | 353 if options.dest: |
353 include['DEST'] = options.dest | 354 include['DEST'] = options.dest |
354 print 'Filter by type: ' + str(options.dest) | 355 print 'Filter by type: ' + str(options.dest) |
355 if args: | 356 if options.projects: |
356 include['NAME'] = args | 357 include['NAME'] = options.projects |
357 print 'Filter by name: ' + str(args) | 358 print 'Filter by name: ' + str(options.projects) |
358 if not options.config: | 359 if not options.config: |
359 options.config = ALL_CONFIGS | 360 options.config = ALL_CONFIGS |
360 | 361 |
361 project_tree = GetProjectTree(include) | 362 project_tree = GetProjectTree(include) |
362 if options.build: | 363 if options.build: |
363 BuildAllTestsInTree(project_tree, options.toolchain, options.config) | 364 BuildAllTestsInTree(project_tree, options.toolchain, options.config) |
364 | 365 |
365 return RunAllTestsInTree(project_tree, options.toolchain, options.config, | 366 return RunAllTestsInTree(project_tree, options.toolchain, options.config, |
366 options.retry_times) | 367 options.retry_times) |
367 | 368 |
368 | 369 |
369 if __name__ == '__main__': | 370 if __name__ == '__main__': |
370 script_name = os.path.basename(sys.argv[0]) | 371 script_name = os.path.basename(sys.argv[0]) |
371 try: | 372 try: |
372 sys.exit(main(sys.argv[1:])) | 373 sys.exit(main(sys.argv[1:])) |
373 except parse_dsc.ValidationError as e: | 374 except parse_dsc.ValidationError as e: |
374 buildbot_common.ErrorExit('%s: %s' % (script_name, e)) | 375 buildbot_common.ErrorExit('%s: %s' % (script_name, e)) |
375 except KeyboardInterrupt: | 376 except KeyboardInterrupt: |
376 buildbot_common.ErrorExit('%s: interrupted' % script_name) | 377 buildbot_common.ErrorExit('%s: interrupted' % script_name) |
OLD | NEW |