summaryrefslogtreecommitdiff
path: root/test/typecheck/run_tests.sh
blob: bfc77899b061896c23e4a194a029aa52a17256ea (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SAILDIR="$DIR/../.."

mkdir -p $DIR/rtpass
mkdir -p $DIR/rtpass2

rm -f $DIR/tests.xml

# shellcheck source=../test_helpers.sh
source "$SAILDIR/test/test_helpers.sh"

printf "<testsuites>\n" >> $DIR/tests.xml

for i in `ls $DIR/pass/ | grep sail`;
do
    if $SAILDIR/sail -no_memo_z3 -just_check -ddump_tc_ast -dsanity $DIR/pass/$i 2> /dev/null 1> $DIR/rtpass/$i;
    then
	if $SAILDIR/sail -no_memo_z3 -just_check -ddump_tc_ast -dmagic_hash -dno_cast -dsanity $DIR/rtpass/$i 2> /dev/null 1> $DIR/rtpass2/$i;
	then
	    if diff $DIR/rtpass/$i $DIR/rtpass2/$i;
	    then
		green "tested $i expecting pass" "pass"
	    else
		yellow "tested $i expecting pass" "re-check AST was different"
	    fi
	else
	    yellow "tested $i expecting pass" "failed re-check"
	fi
    else
	red "tested $i expecting pass" "fail"
    fi;

    shopt -s nullglob;
    for file in $DIR/pass/${i%.sail}/*.sail;
    do
	pushd $DIR/pass > /dev/null;
	if $SAILDIR/sail -no_memo_z3 ${i%.sail}/$(basename $file) 2> result;
	then
	    red "failing variant of $i $(basename $file) passed" "fail"
	else
	    if diff ${file%.sail}.expect result;
	    then
		green "failing variant of $i $(basename $file)" "pass"
	    else
		yellow "failing variant of $i $(basename $file)" "unexpected error"
	    fi
	fi;
	rm -f result;
	popd > /dev/null
    done
done

for file in $DIR/fail/*.sail;
do
    pushd $DIR/fail > /dev/null;
    if $SAILDIR/sail -no_memo_z3 $(basename $file) 2> result
    then
        red "Expected failure, but $(basename $file) passed" "fail"
    else
        if diff ${file%.sail}.expect result;
        then
            green "failing $(basename $file)" "pass"
        else
            yellow "failing $(basename $file)" "unexpected error"
        fi
    fi;
    rm -f result;
    popd > /dev/null
done

finish_suite "Typechecking tests"

printf "</testsuites>\n" >> $DIR/tests.xml