This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tema-checker-local.sh
149 lines (130 loc) · 3.62 KB
/
tema-checker-local.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
#!/bin/bash
GOOD_CODE_STYLE=`echo -ne "Starting audit...\nAudit done.\n"`
BAD_CODE_STYLE=0
totalTests=21
startTest=1
goodTests=0
badTests=0
badHomework=0
inputName="test"
existingReadme=0
badCompile=0
function checkForReadme
{
echo -ne "Checking for README: "
readme=$( find -iname "README" -size +0c | wc -l )
if [[ $readme -eq 1 ]]; then
echo -ne "- OK! \n"
existingReadme=10
else
readme=$( find -iname "README.md" -size +0c | wc -l )
if [[ $readme -eq 1 ]]; then
echo -ne "- OK! \n"
existingReadme=10
else
readme=$( find -iname "README.txt" -size +0c | wc -l)
if [[ $readme -eq 1 ]]; then
echo -ne "- OK! \n"
existingReadme=10
else
echo -ne "- NO README! \n"
existingReadme=0
fi
fi
fi
}
function checkCodeStyle
{
java -jar checker/checkstyle/checkstyle-7.3-all.jar -c checker/checkstyle/poo_checks.xml * > checkstyle.txt
YOUR_CODE_STYLE=`cat checkstyle.txt`
if [[ "$GOOD_CODE_STYLE" != "$YOUR_CODE_STYLE" ]]; then
BAD_CODE_STYLE=`cat checkstyle.txt | grep -o 'Checkstyle ends with [0-9]* errors.' | grep -o '[0-9]*'`
if [[ $BAD_CODE_STYLE -le 30 ]]; then
echo -ne "Checkstyle erros: $BAD_CODE_STYLE .. OK!\n"
BAD_CODE_STYLE=0
else
echo -ne "Checkstyle erros: $BAD_CODE_STYLE .. FAILED!\n"
fi
if [[ $BAD_CODE_STYLE -ge 30 ]]; then
BAD_CODE_STYLE=`expr $BAD_CODE_STYLE - 30`
fi
else
echo -ne "Checkstyle erros: 0 .. OK!\n"
fi
}
function compileHomework
{
make -f VCSMakefile build &>/dev/null
}
compileHomework
if [ $? -eq 0 ]; then
checkForReadme
badCompile=0
if [ "$1" = "fs" ]; then
startTest=16
fi
if [ "$1" = "vcs" ]; then
totalTests=15
fi
rm -rf ./checker/out >/dev/null 2>&1
mkdir ./checker/out >/dev/null 2>&1
for ((nrTest=$startTest; nrTest<=$totalTests; nrTest++))
do
if [ $nrTest -eq 1 ]; then
echo -ne "\nVCS Test .............\n"
fi
if [ $nrTest -eq 16 ]; then
echo -ne "\nFS Test .............\n"
fi
readFrom="./checker/in/test$nrTest.in"
outName="./checker/out/test$nrTest.out"
refName="./checker/ref/test$nrTest.ref"
make -f VCSMakefile arg0=$readFrom arg1=$outName run
if [ $? -ne 0 ]; then
if [ $nrTest -le 9 ]; then
echo -ne "TEST $nrTest: .............. FAILED! Program error!\n"
else
echo -ne "TEST $nrTest: ............. FAILED! Program error!\n"
fi
badTests=$((badTests+1))
badCompile=1
fi
if [[ $badCompile -eq 0 ]]; then
diff $outName $refName &> /dev/null
if [ $? -eq 0 ]; then
if [ $nrTest -le 9 ]; then
echo -ne "TEST $nrTest: .............. OK!\n"
else
echo -ne "TEST $nrTest: ............. OK!\n"
fi
if [ $nrTest -le 15 ]; then
goodTests=$((goodTests+1))
fi
else
if [ $nrTest -ge 16 ]; then
badHomework=1
fi
if [ $nrTest -le 9 ]; then
echo -ne "TEST $nrTest: ............. FAILED!\n"
else
echo -ne "TEST $nrTest: ............. FAILED!\n"
fi
if [ $nrTest -le 15 ]; then
badTests=$((badTests+1))
fi
fi
fi
done
checkCodeStyle
finalPoints=$((goodTests*90/15))
finalPoints=$((finalPoints - BAD_CODE_STYLE + existingReadme))
if [[ $badHomework -eq 1 ]];then
finalPoints=0
badTests="WRONG FileSystem"
fi
echo -ne "BAD TESTS: $badTests\n"
echo -ne "TOTAL POINTS: $finalPoints\n"
make -f VCSMakefile clean &>/dev/null
else
echo -ne "FAIL: Compilation error!\n"
fi