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

Side by Side Diff: native_client_sdk/src/build_tools/test_projects.py

Issue 720233003: [NaCl SDK] Convert python scripts from optparse to argparse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
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
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 # Everything in src is a library, and cannot be run. 302 # Everything in src is a library, and cannot be run.
303 exclude = {'DEST': 'src'} 303 exclude = {'DEST': 'src'}
304 try: 304 try:
305 return parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=include, 305 return parse_dsc.LoadProjectTree(SDK_SRC_DIR, include=include,
306 exclude=exclude) 306 exclude=exclude)
307 except parse_dsc.ValidationError as e: 307 except parse_dsc.ValidationError as e:
308 buildbot_common.ErrorExit(str(e)) 308 buildbot_common.ErrorExit(str(e))
309 309
310 310
311 def main(args): 311 def main(args):
312 parser = optparse.OptionParser() 312 parser = argparse.ArgumentParser(description=__doc__)
313 parser.add_option('-c', '--config', 313 parser.add_argument('-c', '--config',
314 help='Choose configuration to run (Debug or Release). Runs both ' 314 help='Choose configuration to run (Debug or Release). Runs both '
315 'by default', action='append') 315 'by default', action='append')
316 parser.add_option('-x', '--experimental', 316 parser.add_argument('-x', '--experimental',
317 help='Run experimental projects', action='store_true') 317 help='Run experimental projects', action='store_true')
318 parser.add_option('-t', '--toolchain', 318 parser.add_argument('-t', '--toolchain',
319 help='Run using toolchain. Can be passed more than once.', 319 help='Run using toolchain. Can be passed more than once.',
320 action='append', default=[]) 320 action='append', default=[])
321 parser.add_option('-d', '--dest', 321 parser.add_argument('-d', '--dest',
322 help='Select which destinations (project types) are valid.', 322 help='Select which destinations (project types) are valid.',
323 action='append') 323 action='append')
324 parser.add_option('-b', '--build', 324 parser.add_argument('-b', '--build',
325 help='Build each project before testing.', action='store_true') 325 help='Build each project before testing.', action='store_true')
326 parser.add_option('--retry-times', 326 parser.add_argument('--retry-times',
327 help='Number of types to retry on failure (Default: %default)', 327 help='Number of types to retry on failure (Default: %default)',
328 type='int', default=1) 328 type='int', default=1)
329 parser.add_argument('projects')
binji 2014/11/13 23:57:02 nargs='*'
Sam Clegg 2014/11/30 17:55:11 Done.
329 330
330 options, args = parser.parse_args(args[1:]) 331 options = parser.parse_args(args)
331 332
332 if not options.toolchain: 333 if not options.toolchain:
333 options.toolchain = ['newlib', 'glibc', 'pnacl', 'host'] 334 options.toolchain = ['newlib', 'glibc', 'pnacl', 'host']
334 335
335 if 'host' in options.toolchain: 336 if 'host' in options.toolchain:
336 options.toolchain.remove('host') 337 options.toolchain.remove('host')
337 options.toolchain.append(platform) 338 options.toolchain.append(platform)
338 print 'Adding platform: ' + platform 339 print 'Adding platform: ' + platform
339 340
340 ValidateToolchains(options.toolchain) 341 ValidateToolchains(options.toolchain)
341 342
342 include = {} 343 include = {}
343 if options.toolchain: 344 if options.toolchain:
344 include['TOOLS'] = options.toolchain 345 include['TOOLS'] = options.toolchain
345 print 'Filter by toolchain: ' + str(options.toolchain) 346 print 'Filter by toolchain: ' + str(options.toolchain)
346 if not options.experimental: 347 if not options.experimental:
347 include['EXPERIMENTAL'] = False 348 include['EXPERIMENTAL'] = False
348 if options.dest: 349 if options.dest:
349 include['DEST'] = options.dest 350 include['DEST'] = options.dest
350 print 'Filter by type: ' + str(options.dest) 351 print 'Filter by type: ' + str(options.dest)
351 if args: 352 if options.projects:
352 include['NAME'] = args 353 include['NAME'] = options.projects
353 print 'Filter by name: ' + str(args) 354 print 'Filter by name: ' + str(options.projects)
354 if not options.config: 355 if not options.config:
355 options.config = ALL_CONFIGS 356 options.config = ALL_CONFIGS
356 357
357 project_tree = GetProjectTree(include) 358 project_tree = GetProjectTree(include)
358 if options.build: 359 if options.build:
359 BuildAllTestsInTree(project_tree, options.toolchain, options.config) 360 BuildAllTestsInTree(project_tree, options.toolchain, options.config)
360 361
361 return RunAllTestsInTree(project_tree, options.toolchain, options.config, 362 return RunAllTestsInTree(project_tree, options.toolchain, options.config,
362 options.retry_times) 363 options.retry_times)
363 364
364 365
365 if __name__ == '__main__': 366 if __name__ == '__main__':
366 script_name = os.path.basename(sys.argv[0]) 367 script_name = os.path.basename(sys.argv[0])
367 try: 368 try:
368 sys.exit(main(sys.argv)) 369 sys.exit(main(sys.argv[1:]))
369 except parse_dsc.ValidationError as e: 370 except parse_dsc.ValidationError as e:
370 buildbot_common.ErrorExit('%s: %s' % (script_name, e)) 371 buildbot_common.ErrorExit('%s: %s' % (script_name, e))
371 except KeyboardInterrupt: 372 except KeyboardInterrupt:
372 buildbot_common.ErrorExit('%s: interrupted' % script_name) 373 buildbot_common.ErrorExit('%s: interrupted' % script_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698