-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunit_tests.sh
More file actions
executable file
·36 lines (34 loc) · 994 Bytes
/
unit_tests.sh
File metadata and controls
executable file
·36 lines (34 loc) · 994 Bytes
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
#!/bin/bash
#script used for reg testing
COMPILER="./compiler"
LOGFILE='log.txt'
rm -f "$LOGFILE" &>/dev/null
for TESTFILE in ./tests/*.sm;
do
echo " TESTING $TESTFILE" | tee -a "$LOGFILE"
LEN=$((${#TESTFILE}-3))
FILENAME="${TESTFILE:0:$LEN}"
OUTFILENAME="${TESTFILE:0:$LEN}.output"
TESTFILENAME="${TESTFILE:0:$LEN}.out"
echo "Compiling ... " >> "$LOGFILE"
("$COMPILER" "$FILENAME" < "$TESTFILE") 2>> "$LOGFILE"
# if compilation succeeds, run output.py.
if (find $FILENAME.py &>/dev/null)
then
echo "Python runtime output:" >> "$LOGFILE"
(python "$FILENAME.py" > "$OUTFILENAME") 2>> "$LOGFILE"
echo "Diff:\n" >> "$LOGFILE"
touch "$OUTFILENAME"
if (diff "$OUTFILENAME" "$TESTFILENAME" >/dev/null)
then
echo 'OK!' | tee -a "$LOGFILE"
else
colordiff -y "$OUTFILENAME" "$TESTFILENAME"
echo "BAD!" | tee -a "$LOGFILE"
fi
else
echo "BAD!\nCompilation of $TESTFILE FAILED" | tee -a "$LOGFILE"
fi
rm "${FILENAME}.py" "$OUTFILENAME" &>/dev/null
done
exit 0