-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.sh
executable file
·88 lines (73 loc) · 1.81 KB
/
run_tests.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
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd $DIR
ERROR_1=0
ERROR_2=0
ERROR_3=0
function check()
{
ERROR=0
for f in $(find tests/$1 -type f -name "*.lat")
do
echo "$f:"
./latc_x86 $f >> /dev/null
if [[ $? -ne $2 ]] ; then
echo -e "\e[92mOK!\e[0m"
if [[ $2 -eq 1 ]] ; then
if [[ -f "${f%.*}.input" ]] ; then
cat "${f%.*}.input" | ./${f%.*} > ${f%.*}.output.temp
else
./${f%.*} > ${f%.*}.output.temp
fi
if [[ -f "${f%.*}.output" ]] ; then
cmp "${f%.*}.output" "${f%.*}.output.temp"
if [[ $? -eq 0 ]] ; then
echo -e "\e[92mOK!\e[0m"
else
ERROR=1
echo -e "\033[31mERROR OUTPUT!\e[0m"
fi
else
echo -e "\e[92mOK!\e[0m"
fi
rm "${f%.*}"
rm "${f%.*}.output.temp"
fi
else
ERROR=1
echo -e "\033[31mERROR COMPILATION!\e[0m"
fi
done
return $ERROR
}
function print()
{
if [[ $1 -eq 0 ]] ; then
echo -e "\e[92mOK!\e[0m"
else
echo -e "\033[31mFAILED!\e[0m"
fi
}
if [[ $# -eq 0 ]] ; then
echo "BAD TESTS CHECK:"
check "bad" 0
ERROR_1=$?
echo -e "\n\nCORE TESTS CHECK:"
check "good" 1
ERROR_2=$?
echo -e "\n\nEXTENSIONS TESTS CHECK:"
check "extensions" 1
ERROR_3=$?
echo -e "\nBad: "
print $ERROR_1
echo "Core: "
print $ERROR_2
echo "Extensions: "
print $ERROR_3
else
echo $1" check:"
check $1 $2
ERROR=$?
echo -e "\nResult:"
print $ERROR
fi