Changes in src/tests/test.py [fbaebc66:f6ed7fd]
- File:
-
- 1 edited
-
src/tests/test.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/test.py
rfbaebc66 rf6ed7fd 3 3 4 4 from os import listdir 5 from os.path import isfile, join , splitext5 from os.path import isfile, join 6 6 from subprocess import Popen, PIPE, STDOUT 7 7 … … 13 13 ################################################################################ 14 14 def 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 )] 18 19 19 20 return list … … 39 40 40 41 # 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) 42 43 43 44 if make_ret == 0 : … … 50 51 retcode = 0 51 52 if not generate : 53 # touch expected files so empty output are supported by default 54 sh("touch .expect/%s.txt" % test, dry_run) 55 52 56 # diff the output of the files 53 57 retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run) … … 63 67 64 68 if generate : 65 print( "Regenerate tests for: " ) 69 print( "Regenerate tests for: ", end="" ) 70 print( ", ".join( tests ) ) 66 71 67 72 failed = False; 68 73 for t in tests: 69 print("%20s " % t, end="") 74 if not generate : 75 print("%20s " % t, end="") 70 76 sys.stdout.flush() 71 77 test_failed = run_test_instance(t, generate, dry_run) … … 74 80 if not generate : 75 81 print("FAILED" if test_failed else "PASSED") 76 else :77 print( "Done" )78 82 79 83 sh('make clean > /dev/null 2>&1', dry_run) 84 85 if generate : 86 print( "Done" ) 80 87 81 88 return 0 if failed else 1 … … 86 93 parser = argparse.ArgumentParser(description='Script which runs cforall tests') 87 94 parser.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')89 95 parser.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')96 parser.add_argument('--generate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true') 91 97 parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run') 92 98 93 99 options = parser.parse_args() 94 100 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) : 101 if len(options.tests) > 0 and options.all : 97 102 print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr) 98 103 parser.print_help() 99 104 sys.exit(1) 100 105 101 allTests = listTests() 106 tests = listTests() if options.all else options.tests 102 107 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) ) 108 sys.exit( run_tests(tests, options.generate_expected, options.dry_run) )
Note:
See TracChangeset
for help on using the changeset viewer.