-
Notifications
You must be signed in to change notification settings - Fork 7
/
grademe.sh
47 lines (42 loc) · 1.11 KB
/
grademe.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
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
# Setup
echo "What list do you want to correct?"
read LIST
if [[ $LIST != C* ]]
then
echo "Please enter a valid list name, ex: C00, C01, C02, C03, C04, C05, C06"
exit 1
fi
# Check file names
EX_COUNT=$(ls */* | wc -l)
EX_NAMES=$(ls */*)
git clone https://github.com/LucasKuhn/joaonette.git
EXPECTED_NAMES=$(cat joaonette/$LIST/expected_files | head -n $EX_COUNT)
echo "====== filenames ======"
if [[ $(diff <(echo $EX_NAMES) <(echo $EXPECTED_NAMES)) ]]; then
echo -e "KO ${RED}✖${NC}"
echo -e "\n--- DIFF ---"
diff <(echo $EX_NAMES) <(echo $EXPECTED_NAMES)
else
echo -e "OK ${GREEN}✓${NC}"
fi
# Check every exercise
for DIR in ex* ; do
echo "====== $DIR ======"
ERROR=""
mv joaonette/$LIST/$DIR/main.c $DIR/main.c
mv joaonette/$LIST/$DIR/expected_output $DIR/expected_output
cc -Wall -Wextra -Werror -lbsd $DIR/*.c -o $DIR/a.out
./$DIR/a.out > $DIR/user_output
DIFF=$(diff $DIR/user_output $DIR/expected_output)
rm $DIR/a.out
if [[ "$DIFF" == "" ]]; then
echo -e "OK ${GREEN}✓${NC}"
else
echo -e "KO ${RED}✖${NC}"
fi
done
rm -rf joaonette