summaryrefslogtreecommitdiff
path: root/test.sh
blob: a7ba75dca1e0f108cd9531b77bc8ca2ac4d70f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

##################################################
# A test script that uses ./runner.sh to run all #
# tests for a given phase.                       #
##################################################

function java() {
    base="$1"
    if [[ $(basename $base) == *.* ]]; then
        base="${base%.*}"
    fi
    expected=$(bash runner.sh java "${base}.java")
}

function match() {
    [[ "$1" == *"error"* ]] && expected="Type error" ||
            expected="Program type checked successfully"
}

dir1="./output"
dir2=""
case "$1" in
    "heat")
        ext="java"
        comp="match"
        dir2="./output/negative"
        ;;
    "boil")
        ext="java"
        comp="java"
        ;;
    "vaporize")
        ext="vapor"
        comp="java"
        ;;
    "condense")
        ext="vaporm"
        comp="java"
        ;;
    *)
        echo "usage $0 [heat|boil|vaporize|condense]"
        exit 1
        ;;
esac

for dir in "$dir1" "$dir2"; do
    if [ -n "$dir" ] && [ -d "$dir" ]; then
        for file in $dir/*.$ext; do
            [ -f "$file" ] || break
            base=${file%.*}
            echo -n "Processing file: $base "
            $comp $base
            actual=$(bash runner.sh $1 $file 2>/dev/null)
            [[ $expected == $actual ]] && echo 'PASSED' || echo -e "FAILED"
        done
    fi
done