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@323 | 26 | OPTION=$1 |
paul@323 | 27 | |
paul@323 | 28 | # Make any required results directory. |
paul@323 | 29 | |
paul@323 | 30 | if [ "$OPTION" = '--build' ]; then |
paul@323 | 31 | if [ ! -e "_results" ]; then |
paul@323 | 32 | mkdir "_results" |
paul@323 | 33 | else |
paul@323 | 34 | rm "_results/"* |
paul@323 | 35 | fi |
paul@323 | 36 | fi |
paul@323 | 37 | |
paul@323 | 38 | # Perform each test. |
paul@323 | 39 | |
paul@4 | 40 | for FILENAME in tests/* ; do |
paul@323 | 41 | TESTNAME=`basename "$FILENAME" .py` |
paul@4 | 42 | |
paul@4 | 43 | # Detect tests in their own subdirectories. |
paul@4 | 44 | |
paul@4 | 45 | if [ -d "$FILENAME" ] ; then |
paul@4 | 46 | if [ -e "$FILENAME/main.py" ] ; then |
paul@4 | 47 | FILENAME="$FILENAME/main.py" |
paul@4 | 48 | else |
paul@4 | 49 | continue |
paul@4 | 50 | fi |
paul@4 | 51 | fi |
paul@4 | 52 | |
paul@4 | 53 | # Run tests without an existing cache. |
paul@4 | 54 | |
paul@4 | 55 | echo "$FILENAME..." 1>&2 |
paul@275 | 56 | if ! ./lplc "$FILENAME" -r ; then |
paul@275 | 57 | if ! expect_failure; then |
paul@275 | 58 | exit 1 |
paul@275 | 59 | else |
paul@275 | 60 | echo 1>&2 |
paul@275 | 61 | continue |
paul@275 | 62 | fi |
paul@275 | 63 | fi |
paul@39 | 64 | |
paul@39 | 65 | # Check for unresolved names in the cache. |
paul@39 | 66 | |
paul@39 | 67 | echo " (depends)..." 1>&2 |
paul@275 | 68 | if grep '<depends>' -r "_cache" ; then |
paul@45 | 69 | echo "Unresolved names in the cache." 1>&2 |
paul@39 | 70 | exit 1 |
paul@39 | 71 | fi |
paul@4 | 72 | |
paul@45 | 73 | # Check for type warnings in deduction output. |
paul@45 | 74 | |
paul@45 | 75 | echo " (warnings)..." 1>&2 |
paul@45 | 76 | if ! check_type_warnings ; then exit 1 ; fi |
paul@45 | 77 | |
paul@4 | 78 | # Run tests with an existing cache. |
paul@4 | 79 | |
paul@39 | 80 | echo " (cached)..." 1>&2 |
paul@4 | 81 | if ! ./lplc "$FILENAME" ; then exit 1 ; fi |
paul@4 | 82 | |
paul@45 | 83 | echo " (warnings)..." 1>&2 |
paul@45 | 84 | if ! check_type_warnings ; then exit 1 ; fi |
paul@45 | 85 | |
paul@323 | 86 | # Build and run if appropriate. |
paul@323 | 87 | |
paul@323 | 88 | if [ "$OPTION" = '--build' ]; then |
paul@323 | 89 | BUILDLOG="_results/$TESTNAME.build" |
paul@323 | 90 | OUTLOG="_results/$TESTNAME.out" |
paul@323 | 91 | |
paul@323 | 92 | echo " (build)..." 1>&2 |
paul@323 | 93 | if ! make -C _generated clean > "$BUILDLOG" || \ |
paul@323 | 94 | ! make -C _generated > "$BUILDLOG" ; then |
paul@323 | 95 | exit 1 |
paul@323 | 96 | fi |
paul@323 | 97 | |
paul@323 | 98 | echo " (run)..." 1>&2 |
paul@323 | 99 | if ! "_generated/main" > "$OUTLOG" ; then |
paul@323 | 100 | exit 1 |
paul@323 | 101 | fi |
paul@323 | 102 | fi |
paul@323 | 103 | |
paul@45 | 104 | echo 1>&2 |
paul@4 | 105 | done |