paul@4 | 1 | #!/bin/sh |
paul@4 | 2 | |
paul@45 | 3 | # Expect failure from the "bad" tests. |
paul@45 | 4 | |
paul@45 | 5 | expect_failure() { |
paul@45 | 6 | return `echo "$FILENAME" | grep -q '_bad[._]'` |
paul@45 | 7 | } |
paul@45 | 8 | |
paul@45 | 9 | # Check deduction output for type warnings, indicating that the program contains |
paul@45 | 10 | # errors. |
paul@45 | 11 | |
paul@45 | 12 | check_type_warnings() { |
paul@45 | 13 | |
paul@45 | 14 | if [ -e "_deduced/type_warnings" ] && \ |
paul@275 | 15 | [ `stat -c %s "_deduced/type_warnings"` -ne 0 ] ; then |
paul@45 | 16 | |
paul@45 | 17 | echo "Type warnings in deduced information." 1>&2 |
paul@45 | 18 | return 1 |
paul@45 | 19 | fi |
paul@45 | 20 | |
paul@45 | 21 | return 0 |
paul@45 | 22 | } |
paul@45 | 23 | |
paul@45 | 24 | # Main program. |
paul@45 | 25 | |
paul@4 | 26 | for FILENAME in tests/* ; do |
paul@4 | 27 | |
paul@4 | 28 | # Detect tests in their own subdirectories. |
paul@4 | 29 | |
paul@4 | 30 | if [ -d "$FILENAME" ] ; then |
paul@4 | 31 | if [ -e "$FILENAME/main.py" ] ; then |
paul@4 | 32 | FILENAME="$FILENAME/main.py" |
paul@4 | 33 | else |
paul@4 | 34 | continue |
paul@4 | 35 | fi |
paul@4 | 36 | fi |
paul@4 | 37 | |
paul@4 | 38 | # Run tests without an existing cache. |
paul@4 | 39 | |
paul@4 | 40 | echo "$FILENAME..." 1>&2 |
paul@275 | 41 | if ! ./lplc "$FILENAME" -r ; then |
paul@275 | 42 | if ! expect_failure; then |
paul@275 | 43 | exit 1 |
paul@275 | 44 | else |
paul@275 | 45 | echo 1>&2 |
paul@275 | 46 | continue |
paul@275 | 47 | fi |
paul@275 | 48 | fi |
paul@39 | 49 | |
paul@39 | 50 | # Check for unresolved names in the cache. |
paul@39 | 51 | |
paul@39 | 52 | echo " (depends)..." 1>&2 |
paul@275 | 53 | if grep '<depends>' -r "_cache" ; then |
paul@45 | 54 | echo "Unresolved names in the cache." 1>&2 |
paul@39 | 55 | exit 1 |
paul@39 | 56 | fi |
paul@4 | 57 | |
paul@45 | 58 | # Check for type warnings in deduction output. |
paul@45 | 59 | |
paul@45 | 60 | echo " (warnings)..." 1>&2 |
paul@45 | 61 | if ! check_type_warnings ; then exit 1 ; fi |
paul@45 | 62 | |
paul@4 | 63 | # Run tests with an existing cache. |
paul@4 | 64 | |
paul@39 | 65 | echo " (cached)..." 1>&2 |
paul@4 | 66 | if ! ./lplc "$FILENAME" ; then exit 1 ; fi |
paul@4 | 67 | |
paul@45 | 68 | echo " (warnings)..." 1>&2 |
paul@45 | 69 | if ! check_type_warnings ; then exit 1 ; fi |
paul@45 | 70 | |
paul@45 | 71 | echo 1>&2 |
paul@4 | 72 | done |