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 for FILENAME in tests/* ; do 27 28 # Detect tests in their own subdirectories. 29 30 if [ -d "$FILENAME" ] ; then 31 if [ -e "$FILENAME/main.py" ] ; then 32 FILENAME="$FILENAME/main.py" 33 else 34 continue 35 fi 36 fi 37 38 # Run tests without an existing cache. 39 40 echo "$FILENAME..." 1>&2 41 if ! ./lplc "$FILENAME" -r ; then 42 if ! expect_failure; then 43 exit 1 44 else 45 echo 1>&2 46 continue 47 fi 48 fi 49 50 # Check for unresolved names in the cache. 51 52 echo " (depends)..." 1>&2 53 if grep '<depends>' -r "_cache" ; then 54 echo "Unresolved names in the cache." 1>&2 55 exit 1 56 fi 57 58 # Check for type warnings in deduction output. 59 60 echo " (warnings)..." 1>&2 61 if ! check_type_warnings ; then exit 1 ; fi 62 63 # Run tests with an existing cache. 64 65 echo " (cached)..." 1>&2 66 if ! ./lplc "$FILENAME" ; then exit 1 ; fi 67 68 echo " (warnings)..." 1>&2 69 if ! check_type_warnings ; then exit 1 ; fi 70 71 echo 1>&2 72 done