- Timestamp:
- Jun 16, 2016, 12:45:43 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, 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, qualifiedEnum, resolv-new, with_gc
- Children:
- 14d2bdf, 3689906
- Parents:
- 245510f
- Location:
- src/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/.expect/vector_test.txt
r245510f r3c1d702 1 make: *** No rule to make target `vector_int.c', needed by `vector_int.o'. Stop. 2 /bin/sh: ./vector_test: Is a directory 1 enter N elements and C-d on a separate line: 2 Array elements: 3 1 2 3 4 5 4 Array elements reversed: 5 5 4 3 2 1 -
src/tests/test.py
r245510f r3c1d702 32 32 # running test functions 33 33 ################################################################################ 34 def run_test_instance(test, dry_run): 35 sh("rm -f .out/%s.log" % test, dry_run) 34 def run_test_instance(test, generate, dry_run): 35 36 out_file = (".out/%s.log" % test) if not generate else (".expect/%s.txt" % test) 37 38 sh("rm -f %s" % out_file, dry_run) 36 39 sh("rm -f %s > /dev/null 2>&1" % test, dry_run) 37 40 38 41 # build, skipping to next test on error 39 sh("make -j 1 %s >> .out/%s.log 2>&1" % (test, test), dry_run)42 make_ret = sh("make -j 1 %s > %s 2>&1" % (test, out_file), dry_run) 40 43 41 # fetch optional input 42 stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else "" 44 if make_ret == 0 : 45 # fetch optional input 46 stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else "" 43 47 44 # run test45 sh("./%s %s >> .out/%s.log 2>&1" % (test, stdinput, test), dry_run)48 # run test 49 sh("./%s %s > %s 2>&1" % (test, stdinput, out_file), dry_run) 46 50 47 # touch expected files so empty output are supported by default 48 sh("touch .expect/%s.txt" % test, dry_run) 51 retcode = 0 52 if not generate : 53 # touch expected files so empty output are supported by default 54 sh("touch .expect/%s.txt" % test, dry_run) 49 55 50 # diff the output of the files51 retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)56 # diff the output of the files 57 retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run) 52 58 53 59 # clean the executable … … 56 62 return retcode 57 63 58 def run_tests(tests, dry_run) :64 def run_tests(tests, generate, dry_run) : 59 65 sh('make clean > /dev/null 2>&1', dry_run) 66 sh('mkdir -p .out .expect', dry_run) 67 68 if generate : 69 print( "Regenerate tests for: ", end="" ) 70 print( ", ".join( tests ) ) 60 71 61 72 failed = False; 62 73 for t in tests: 63 print("%10s " % t, end="") 74 if not generate : 75 print("%20s " % t, end="") 64 76 sys.stdout.flush() 65 test_failed = run_test_instance(t, dry_run)77 test_failed = run_test_instance(t, generate, dry_run) 66 78 failed = test_failed or failed 67 print("FAILED" if test_failed else "PASSED") 79 80 if not generate : 81 print("FAILED" if test_failed else "PASSED") 68 82 69 83 sh('make clean > /dev/null 2>&1', dry_run) 70 84 85 if generate : 86 print( "Done" ) 87 71 88 return 0 if failed else 1 72 73 ################################################################################74 # generate expectation functions75 ################################################################################76 def generate_test_expect(test):77 sh("rm -f .out/%s.log" % test, False)78 sh("rm -f %s > /dev/null 2>&1" % test, False)79 80 # build, skipping to next test on error81 sh("make -j 8 %s > .expect/%s.txt 2>&1" % (test, test), False)82 83 # fetch optional input84 stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else ""85 86 # run test87 sh("./%s %s >> .expect/%s.txt 2>&1" % (test, stdinput, test), False)88 89 # clean the executable90 sh("rm -f %s > /dev/null 2>&1" % test, False)91 92 def generate_expect(tests) :93 sh('make clean > /dev/null 2>&1', False)94 95 print( "Regenerate tests for" )96 97 print( ", ".join( tests ) )98 99 for t in tests:100 generate_test_expect( t )101 102 print( "Done" )103 104 sh('make clean > /dev/null 2>&1', False)105 89 106 90 ################################################################################ … … 115 99 options = parser.parse_args() 116 100 117 tests = listTests() 101 if len(options.tests) > 0 and options.all : 102 print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr) 103 parser.print_help() 104 sys.exit(1) 118 105 119 if options.all : 120 if len(options.tests) > 0 : 121 print('ERROR: cannot specify tests with \'--all\' option', file=sys.stderr) 122 sys.exit(1) 106 tests = listTests() if options.all else options.tests 123 107 124 if options.generate_expected : 125 generate_expect( tests ) 126 else : 127 sys.exit( run_tests(tests, options.dry_run) ) 128 129 else : 130 if len(options.tests) == 0 : 131 print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr) 132 parser.print_help() 133 sys.exit(1) 134 135 if options.generate_expected : 136 generate_expect( options.tests ) 137 else : 138 sys.exit( run_tests(options.tests, options.dry_run) ) 139 140 sys.exit(0) 108 sys.exit( run_tests(tests, options.generate_expected, options.dry_run) )
Note: See TracChangeset
for help on using the changeset viewer.