Changeset b98c913


Ignore:
Timestamp:
Apr 27, 2017, 12:48:40 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
075d862
Parents:
86c8fd6
Message:

Removed unnecessary test input.
Added some support for test command line completion.
Test script now always runs from the src/test folder.

Location:
src/tests
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    r86c8fd6 rb98c913  
    268268#               main loop
    269269################################################################################
     270abspath = os.path.abspath(__file__)
     271dname = os.path.dirname(abspath)
     272os.chdir(dname)
     273
    270274# create a parser with the arguments for the tests script
    271275parser = argparse.ArgumentParser(description='Script which runs cforall tests')
     
    277281parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
    278282parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously', type=int, default='8')
     283parser.add_argument('--list-comp', help='List all valide arguments', action='store_true')
    279284parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run')
     285
    280286
    281287# parse the command line arguments
    282288options = parser.parse_args()
     289do_list = options.list or options.list_comp
    283290
    284291# 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) :
     292if (len(options.tests) > 0  and     options.all and not do_list) \
     293or (len(options.tests) == 0 and not options.all and not do_list) :
    287294        print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr)
    288295        parser.print_help()
     
    293300
    294301# if user wants all tests than no other treatement of the test list is required
    295 if options.all or options.list :
     302if options.all or do_list :
    296303        tests = allTests
    297304
     
    328335tests.sort(key=lambda t: t.name)
    329336
    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
     338if 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
     342elif options.list :
     343        print("\n".join(map(lambda t: "%s (%s)" % (t.name, t.path), tests)))
     344
    337345else :
    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
    355366        # otherwise run all tests and make sure to return the correct error code
    356367        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.