Changeset 0534c3c


Ignore:
Timestamp:
Jun 20, 2016, 10:53:22 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, resolv-new, with_gc
Children:
fbaebc6
Parents:
ebcd82b
Message:

tests now use .expect folder to list available tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/test.py

    rebcd82b r0534c3c  
    33
    44from os import listdir
    5 from os.path import isfile, join
     5from os.path import isfile, join, splitext
    66from subprocess import Popen, PIPE, STDOUT
    77
     
    1313################################################################################
    1414def listTests():
    15         list = [f.rstrip('.c') for f in listdir('.')
    16                 if not f.startswith('.') and (
    17                         not isfile(f) or f.endswith('.c')
    18                 )]
     15        list = [splitext(f)[0] for f in listdir('./.expect')
     16                if not f.startswith('.') and f.endswith('.txt')
     17                ]
    1918
    2019        return list
     
    5150        retcode = 0
    5251        if not generate :
    53                 # touch expected files so empty output are supported by default
    54                 sh("touch .expect/%s.txt" % test, dry_run)
    55 
    5652                # diff the output of the files
    5753                retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
     
    9086parser = argparse.ArgumentParser(description='Script which runs cforall tests')
    9187parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
     88parser.add_argument('--list', help='List all test available', action='store_true')
    9289parser.add_argument('--all', help='Run all test available', action='store_true')
    93 parser.add_argument('--generate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
     90parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
    9491parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run')
    9592
    9693options = parser.parse_args()
    9794
    98 if len(options.tests) > 0 and options.all :
     95if (len(options.tests) > 0  and     options.all and not options.list) \
     96or (len(options.tests) == 0 and not options.all and not options.list) :
    9997        print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr)
    10098        parser.print_help()
    10199        sys.exit(1)
    102100
    103 tests = listTests() if options.all else options.tests
     101allTests = listTests()
    104102
    105 sys.exit( run_tests(tests, options.generate_expected, options.dry_run) )
     103if options.all or options.list :
     104        tests = allTests
     105
     106else :
     107        tests = []
     108        for test in options.tests:
     109                if allTests.contains( test ) :
     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
     118if options.list :
     119        print("\n".join(tests))
     120
     121else :
     122        sys.exit( run_tests(tests, options.regenerate_expected, options.dry_run) )
Note: See TracChangeset for help on using the changeset viewer.