Lichen

Annotated test_all.sh

95:a0f513d3a7b1
2016-10-13 Paul Boddie Fixed instruction plan test operations, optimised the initial accessor to avoid redundant assignments and to use the context where appropriate, introduced accessor and attribute name parameterisation in the generated instructions, introduced a generic expression placeholder in place of any local name.
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@45 15
       [ `stat -c %s "_deduced/type_warnings"` -ne 0 ] && \
paul@45 16
       ! expect_failure ; then
paul@45 17
paul@45 18
       echo "Type warnings in deduced information." 1>&2
paul@45 19
       return 1
paul@45 20
    fi
paul@45 21
paul@45 22
    return 0
paul@45 23
}
paul@45 24
paul@45 25
# Main program.
paul@45 26
paul@4 27
for FILENAME in tests/* ; do
paul@4 28
paul@4 29
    # Detect tests in their own subdirectories.
paul@4 30
paul@4 31
    if [ -d "$FILENAME" ] ; then
paul@4 32
        if [ -e "$FILENAME/main.py" ] ; then
paul@4 33
            FILENAME="$FILENAME/main.py"
paul@4 34
        else
paul@4 35
            continue
paul@4 36
        fi
paul@4 37
    fi
paul@4 38
paul@4 39
    # Run tests without an existing cache.
paul@4 40
paul@4 41
    echo "$FILENAME..." 1>&2
paul@4 42
    if ! ./lplc "$FILENAME" -r ; then exit 1 ; fi
paul@39 43
paul@39 44
    # Check for unresolved names in the cache.
paul@39 45
paul@39 46
    echo " (depends)..." 1>&2
paul@39 47
    if grep '<depends>' -r "_cache" && \
paul@45 48
       ! expect_failure ; then
paul@45 49
paul@45 50
       echo "Unresolved names in the cache." 1>&2
paul@39 51
       exit 1
paul@39 52
    fi
paul@4 53
paul@45 54
    # Check for type warnings in deduction output.
paul@45 55
paul@45 56
    echo " (warnings)..." 1>&2
paul@45 57
    if ! check_type_warnings ; then exit 1 ; fi
paul@45 58
paul@4 59
    # Run tests with an existing cache.
paul@4 60
paul@39 61
    echo " (cached)..." 1>&2
paul@4 62
    if ! ./lplc "$FILENAME" ; then exit 1 ; fi
paul@4 63
paul@45 64
    echo " (warnings)..." 1>&2
paul@45 65
    if ! check_type_warnings ; then exit 1 ; fi
paul@45 66
paul@45 67
    echo 1>&2
paul@4 68
done