-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtests.sh
executable file
·160 lines (131 loc) · 3.15 KB
/
runtests.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
if ! [ -e interpreter ]
then make all
fi
tests=$(find tests -name *\.corgi)
had_failures="0"
ast_suffix=".astout"
sym_suffix=".symout"
sem_suffix=".semout"
intermed_suffix=".java"
ast_outdir="astout"
sym_outdir="symout"
sem_outdir="semout"
intermed_outdir="intermedout"
final_outdir="finalout"
get_test_name () {
local fullpath=$1
testpath="${fullpath%.*}"
test_name="${testpath##*/}"
}
# Testing AST
echo ""
echo "----------------Testing Abstract Syntax Tree Output----------------"
echo ""
for file in $tests
do
get_test_name "$file"
./interpreter -ast < "$file" 2> ".test_out"
if [[ ! $(diff ".test_out" "tests/$ast_outdir/$test_name$ast_suffix") ]]
then
echo "success: $test_name"
else
echo "FAIL: $test_name"
had_failures="1"
printf "Expected: {\n"
cat "tests/$ast_outdir/$test_name$ast_suffix"
printf "}\n"
echo
printf "Recieved: {\n"
cat ".test_out"
printf "}\n"
echo
fi
done
# Testing Symbol Tables
echo ""
echo "----------------Testing Symbol Table Output----------------"
echo ""
for file in $tests
do
get_test_name "$file"
./interpreter -sym < "$file" 2> ".test_out"
if [[ ! $(diff ".test_out" "tests/$sym_outdir/$test_name$sym_suffix") ]]
then
echo "success: $test_name"
else
echo "FAIL: $test_name"
had_failures="1"
printf "Expected: {\n"
cat "tests/$sym_outdir/$test_name$sym_suffix"
printf "}\n"
echo
printf "Recieved: {\n"
cat ".test_out"
printf "}\n"
echo
fi
done
# Testing Symbol Tables
echo ""
echo "----------------Testing Semantic Checking Output----------------"
echo ""
for file in $tests
do
get_test_name "$file"
./interpreter -sem < "$file" 2> ".test_out"
if [[ ! $(diff ".test_out" "tests/$sem_outdir/$test_name$sem_suffix") ]]
then
echo "success: $test_name"
else
echo "FAIL: $test_name"
had_failures="1"
printf "Expected: {\n"
cat "tests/$sem_outdir/$test_name$sem_suffix"
printf "}\n"
echo
printf "Recieved: {\n"
cat ".test_out"
printf "}\n"
echo
fi
done
# Testing Final Output
: '
echo ""
echo "----------------Testing Final Output----------------"
echo ""
for file in $tests
do
get_test_name "$file"
./interpreter -javagen < "$file" 2> ".test_out"
cp .test_out javaclasses/Intermediate.java
cd javaclasses
javac Intermediate.java
java Intermediate > ../.test_out
rm Intermediate.java
rm Intermediate.class
cd ..
if [[ ! $(diff ".test_out" "tests/$final_outdir/$test_name.txt") ]]
then
echo "success: $test_name"
else
echo "FAIL: $test_name"
had_failures="1"
printf "Expected: {\n"
cat "tests/$final_outdir/$test_name.txt"
printf "}\n"
echo
printf "Recieved: {\n"
cat ".test_out"
printf "}\n"
echo
fi
done
'
echo ""
echo "----------------Finished Testing, Running Make Clean----------------"
echo ""
rm -f ".test_out"
make clean
exit $had_failures