Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    rfbaebc66 rf6ed7fd  
    33
    44from os import listdir
    5 from os.path import isfile, join, splitext
     5from os.path import isfile, join
    66from subprocess import Popen, PIPE, STDOUT
    77
     
    1313################################################################################
    1414def listTests():
    15         list = [splitext(f)[0] for f in listdir('./.expect')
    16                 if not f.startswith('.') and f.endswith('.txt')
    17                 ]
     15        list = [f.rstrip('.c') for f in listdir('.')
     16                if not f.startswith('.') and (
     17                        not isfile(f) or f.endswith('.c')
     18                )]
    1819
    1920        return list
     
    3940
    4041        # build, skipping to next test on error
    41         make_ret = sh("make -j 8 %s 2> %s 1> /dev/null" % (test, out_file), dry_run)
     42        make_ret = sh("make -j 8 %s > %s 2>&1" % (test, out_file), dry_run)
    4243
    4344        if make_ret == 0 :
     
    5051        retcode = 0
    5152        if not generate :
     53                # touch expected files so empty output are supported by default
     54                sh("touch .expect/%s.txt" % test, dry_run)
     55
    5256                # diff the output of the files
    5357                retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
     
    6367
    6468        if generate :
    65                 print( "Regenerate tests for: " )
     69                print( "Regenerate tests for: ", end="" )
     70                print( ", ".join( tests ) )
    6671
    6772        failed = False;
    6873        for t in tests:
    69                 print("%20s  " % t, end="")
     74                if not generate :
     75                        print("%20s  " % t, end="")
    7076                sys.stdout.flush()
    7177                test_failed = run_test_instance(t, generate, dry_run)
     
    7480                if not generate :
    7581                        print("FAILED" if test_failed else "PASSED")
    76                 else :
    77                         print( "Done" )
    7882
    7983        sh('make clean > /dev/null 2>&1', dry_run)
     84
     85        if generate :
     86                print( "Done" )
    8087
    8188        return 0 if failed else 1
     
    8693parser = argparse.ArgumentParser(description='Script which runs cforall tests')
    8794parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
    88 parser.add_argument('--list', help='List all test available', action='store_true')
    8995parser.add_argument('--all', help='Run all test available', action='store_true')
    90 parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
     96parser.add_argument('--generate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
    9197parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run')
    9298
    9399options = parser.parse_args()
    94100
    95 if (len(options.tests) > 0  and     options.all and not options.list) \
    96 or (len(options.tests) == 0 and not options.all and not options.list) :
     101if len(options.tests) > 0 and options.all :
    97102        print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr)
    98103        parser.print_help()
    99104        sys.exit(1)
    100105
    101 allTests = listTests()
     106tests = listTests() if options.all else options.tests
    102107
    103 if options.all or options.list :
    104         tests = allTests
    105 
    106 else :
    107         tests = []
    108         for test in options.tests:
    109                 if test in allTests :
    110                         tests.append(test)
    111                 else :
    112                         print('ERROR: No expected file for test %s, ignoring it' % test, file=sys.stderr)
    113 
    114         if len(tests) == 0 :
    115                 print('ERROR: No valid test to run', file=sys.stderr)
    116                 sys.exit(1)
    117 
    118 if options.list :
    119         print("\n".join(tests))
    120 
    121 else :
    122         sys.exit( run_tests(tests, options.regenerate_expected, options.dry_run) )
     108sys.exit( run_tests(tests, options.generate_expected, options.dry_run) )
Note: See TracChangeset for help on using the changeset viewer.