Changeset 6a1bdfd for src/tests/test.py


Ignore:
Timestamp:
Dec 13, 2016, 5:42:53 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
cc640aad
Parents:
37efaf56
Message:

Python test script now supports both debug and no debug tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    r37efaf56 r6a1bdfd  
    104104#               running test functions
    105105################################################################################
    106 def run_single_test(test, generate, dry_run):
     106def run_single_test(test, generate, dry_run, debug):
    107107
    108108        # find the output file based on the test name and options flag
     
    113113        sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
    114114
     115        options = "-debug" if debug else "-nodebug";
     116
    115117        # build, skipping to next test on error
    116         make_ret, _ = sh("%s %s 2> %s 1> /dev/null" % (make_cmd, test.name, out_file), dry_run)
     118        make_ret, _ = sh("""%s CFLAGS="-quiet %s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
    117119
    118120        # if the make command succeds continue otherwise skip to diff
     
    165167        return retcode, error
    166168
    167 def run_test_instance(t, generate, dry_run) :
     169def run_test_instance(t, generate, dry_run, debug) :
    168170        # print formated name
    169171        name_txt = "%20s  " % t.name
    170172
    171173        #run the test instance and collect the result
    172         test_failed, error = run_single_test(t, generate, dry_run)
     174        test_failed, error = run_single_test(t, generate, dry_run, debug)
    173175
    174176        # update output based on current action
     
    194196
    195197# run the given list of tests with the given parameters
    196 def run_tests(tests, generate, dry_run, jobs) :
     198def run_tests(tests, generate, dry_run, jobs, debug) :
    197199        # clean the sandbox from previous commands
    198200        sh("%s clean > /dev/null 2>&1" % make_cmd, dry_run)
     
    207209        pool = Pool(jobs)
    208210        try :
    209                 results = pool.map_async(partial(run_test_instance, generate=generate, dry_run=dry_run), tests ).get(99999999)
     211                results = pool.map_async(partial(run_test_instance, generate=generate, dry_run=dry_run, debug=debug), tests ).get(99999999)
    210212        except KeyboardInterrupt:
    211213                pool.terminate()
     
    222224        return 0
    223225
     226def yes_no(string):
     227        if string == "yes" :
     228                return True
     229        if string == "no" :
     230                return False
     231        raise argparse.ArgumentTypeError(msg)
     232        return False
     233
     234
    224235################################################################################
    225236#               main loop
     
    227238# create a parser with the arguments for the tests script
    228239parser = argparse.ArgumentParser(description='Script which runs cforall tests')
     240parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='no')
    229241parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
    230242parser.add_argument('--list', help='List all test available', action='store_true')
     
    296308        sys.exit(1)
    297309
    298 print('Running on %i cores' % options.jobs)
     310print('Running (%s) on %i cores' % ("debug" if options.debug else "no debug", options.jobs))
    299311make_cmd = "make" if make_flags else ("make -j%i" % options.jobs)
    300312
     
    305317else :
    306318        # otherwise run all tests and make sure to return the correct error code
    307         sys.exit( run_tests(tests, options.regenerate_expected, options.dry_run, options.jobs) )
     319        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.