1 #!/bin/sh 2 3 # Expect failure from the "bad" tests. 4 5 expect_failure() { 6 return `echo "$FILENAME" | grep -q '_bad[._]'` 7 } 8 9 # Check deduction output for type warnings, indicating that the program contains 10 # errors. 11 12 check_type_warnings() { 13 14 if [ -e "_deduced/type_warnings" ] && \ 15 [ `stat -c %s "_deduced/type_warnings"` -ne 0 ] ; then 16 17 echo "Type warnings in deduced information." 1>&2 18 return 1 19 fi 20 21 return 0 22 } 23 24 # Main program. 25 26 OPTION=$1 27 28 # Make any required results directory. 29 30 if [ "$OPTION" = '--build' ]; then 31 if [ ! -e "_results" ]; then 32 mkdir "_results" 33 else 34 rm "_results/"* 35 fi 36 fi 37 38 # Perform each test. 39 40 for FILENAME in tests/* ; do 41 TESTNAME=`basename "$FILENAME" .py` 42 43 # Detect tests in their own subdirectories. 44 45 if [ -d "$FILENAME" ] ; then 46 if [ -e "$FILENAME/main.py" ] ; then 47 FILENAME="$FILENAME/main.py" 48 else 49 continue 50 fi 51 fi 52 53 # Run tests without an existing cache. 54 55 echo "$FILENAME..." 1>&2 56 if ! ./lplc "$FILENAME" -r ; then 57 if ! expect_failure; then 58 exit 1 59 else 60 echo 1>&2 61 continue 62 fi 63 fi 64 65 # Check for unresolved names in the cache. 66 67 echo " (depends)..." 1>&2 68 if grep '<depends>' -r "_cache" ; then 69 echo "Unresolved names in the cache." 1>&2 70 exit 1 71 fi 72 73 # Check for type warnings in deduction output. 74 75 echo " (warnings)..." 1>&2 76 if ! check_type_warnings ; then exit 1 ; fi 77 78 # Run tests with an existing cache. 79 80 echo " (cached)..." 1>&2 81 if ! ./lplc "$FILENAME" ; then exit 1 ; fi 82 83 echo " (warnings)..." 1>&2 84 if ! check_type_warnings ; then exit 1 ; fi 85 86 # Build and run if appropriate. 87 88 if [ "$OPTION" = '--build' ]; then 89 BUILDLOG="_results/$TESTNAME.build" 90 OUTLOG="_results/$TESTNAME.out" 91 92 echo " (build)..." 1>&2 93 if ! make -C _generated clean > "$BUILDLOG" || \ 94 ! make -C _generated > "$BUILDLOG" ; then 95 exit 1 96 fi 97 98 echo " (run)..." 1>&2 99 if ! "_generated/main" > "$OUTLOG" ; then 100 exit 1 101 fi 102 fi 103 104 echo 1>&2 105 done