- Timestamp:
- Apr 27, 2017, 12:48:40 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 075d862
- Parents:
- 86c8fd6
- Location:
- src/tests
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/test.py
r86c8fd6 rb98c913 268 268 # main loop 269 269 ################################################################################ 270 abspath = os.path.abspath(__file__) 271 dname = os.path.dirname(abspath) 272 os.chdir(dname) 273 270 274 # create a parser with the arguments for the tests script 271 275 parser = argparse.ArgumentParser(description='Script which runs cforall tests') … … 277 281 parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true') 278 282 parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously', type=int, default='8') 283 parser.add_argument('--list-comp', help='List all valide arguments', action='store_true') 279 284 parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run') 285 280 286 281 287 # parse the command line arguments 282 288 options = parser.parse_args() 289 do_list = options.list or options.list_comp 283 290 284 291 # script must have at least some tests to run 285 if (len(options.tests) > 0 and options.all and not options.list) \286 or (len(options.tests) == 0 and not options.all and not options.list) :292 if (len(options.tests) > 0 and options.all and not do_list) \ 293 or (len(options.tests) == 0 and not options.all and not do_list) : 287 294 print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr) 288 295 parser.print_help() … … 293 300 294 301 # if user wants all tests than no other treatement of the test list is required 295 if options.all or options.list :302 if options.all or do_list : 296 303 tests = allTests 297 304 … … 328 335 tests.sort(key=lambda t: t.name) 329 336 330 # check if the user already passed in a number of jobs for multi-threading 331 make_flags = environ.get('MAKEFLAGS') 332 make_jobs_fds = re.search("--jobserver-(auth|fds)=\s*([0-9]+),([0-9]+)", make_flags) if make_flags else None 333 if make_jobs_fds : 334 tokens = os.read(int(make_jobs_fds.group(2)), 1024) 335 options.jobs = len(tokens) 336 os.write(int(make_jobs_fds.group(3)), tokens) 337 # users may want to simply list the tests 338 if options.list_comp : 339 print("-h --help --debug --concurrent --dry-run --list --all --regenerate-expected -j --jobs ", end='') 340 print(" ".join(map(lambda t: "%s" % (t.name), tests))) 341 342 elif options.list : 343 print("\n".join(map(lambda t: "%s (%s)" % (t.name, t.path), tests))) 344 337 345 else : 338 options.jobs = multiprocessing.cpu_count() 339 340 # make sure we have a valid number of jobs that corresponds to user input 341 if options.jobs <= 0 : 342 print('ERROR: Invalid number of jobs', file=sys.stderr) 343 sys.exit(1) 344 345 options.jobs = min( options.jobs, len(tests) ) 346 347 print('Running (%s) on %i cores' % ("debug" if options.debug else "no debug", options.jobs)) 348 make_cmd = "make" if make_flags else ("make -j%i" % options.jobs) 349 350 # users may want to simply list the tests 351 if options.list : 352 print("\n".join(map(lambda t: "%s (%s)" % (t.name, t.path), tests))) 353 354 else : 346 # check if the user already passed in a number of jobs for multi-threading 347 make_flags = environ.get('MAKEFLAGS') 348 make_jobs_fds = re.search("--jobserver-(auth|fds)=\s*([0-9]+),([0-9]+)", make_flags) if make_flags else None 349 if make_jobs_fds : 350 tokens = os.read(int(make_jobs_fds.group(2)), 1024) 351 options.jobs = len(tokens) 352 os.write(int(make_jobs_fds.group(3)), tokens) 353 else : 354 options.jobs = multiprocessing.cpu_count() 355 356 # make sure we have a valid number of jobs that corresponds to user input 357 if options.jobs <= 0 : 358 print('ERROR: Invalid number of jobs', file=sys.stderr) 359 sys.exit(1) 360 361 options.jobs = min( options.jobs, len(tests) ) 362 363 print('Running (%s) on %i cores' % ("debug" if options.debug else "no debug", options.jobs)) 364 make_cmd = "make" if make_flags else ("make -j%i" % options.jobs) 365 355 366 # otherwise run all tests and make sure to return the correct error code 356 367 sys.exit( run_tests(tests, options.regenerate_expected, options.dry_run, options.jobs, options.debug) )
Note: See TracChangeset
for help on using the changeset viewer.