-
Notifications
You must be signed in to change notification settings - Fork 1
/
gradelab2.sh
executable file
·56 lines (49 loc) · 1.14 KB
/
gradelab2.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
#!/bin/bash
BIN=test_lex
REFOUTDIR=refs
TESTCASEDIR=testcases
base_name=$(basename "$PWD")
if [[ ! $base_name =~ "tiger-compiler" ]]; then
echo "[-_-]: Not in Lab Root Dir"
echo "SCORE: 0"
exit 1
fi
mkdir -p build
cd build
rm -f testcases refs _tmp.txt .tmp.txt
ln -s ../testdata/lab2/testcases testcases
if [[ $? != 0 ]]; then
echo "[-_-]$ite: Link Error"
echo "TOTAL SCORE: 0"
exit 123
fi
ln -s ../testdata/lab2/refs refs
if [[ $? != 0 ]]; then
echo "[-_-]$ite: Link Error"
echo "TOTAL SCORE: 0"
exit 123
fi
cmake .. >&/dev/null
make ${BIN} -j >/dev/null
if [[ $? != 0 ]]; then
echo "[-_-]$ite: Compile Error"
echo "TOTAL SCORE: 0"
exit 123
fi
for tcase in $(ls $TESTCASEDIR); do
if [ ${tcase##*.} = "tig" ]; then
tfileName=${tcase##*/}
./$BIN $TESTCASEDIR/$tfileName >&_tmp.txt
diff $DIFFOPTION _tmp.txt $REFOUTDIR/${tfileName%.*}.out >&.tmp.txt
if [ -s .tmp.txt ]; then
cat .tmp.txt
echo "[*_*]$ite: Output Mismatch [$tfileName]"
rm -f _tmp.txt .tmp.txt
echo "TOTAL SCORE: 0"
exit 234
fi
fi
done
rm -f testcases refs _tmp.txt .tmp.txt
echo "[^_^]$ite: Pass"
echo "TOTAL SCORE: 100"