-
Notifications
You must be signed in to change notification settings - Fork 0
/
grademe.sh
executable file
·69 lines (59 loc) · 1.64 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# --------------------------------- color def -------------------------------- #
THICK="\033[1m"
CYAN="\033[1;36m"
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
RESET="\033[m"
PROMPT="${CYAN}$>${RESET}"
INFO=$CYAN
ERROR="${THICK}[ ${RED}ERROR${RESET} ${THICK}]"
OK="${THICK}[ ${GREEN}OK${RESET} ${THICK}]"
EOL="\n${RESET}"
# --------------------------------- settings --------------------------------- #
logfile="result.log"
stdfile="std.log"
option=""
# ------------------------------ setup arguments ----------------------------- #
if [ $# == 0 ]; then
:
elif [ $1 == "vector" ]; then
option="vector"
elif [ $1 == "map" ]; then
option="map"
elif [ $1 == "stack" ]; then
option="stack"
elif [ $1 == "set" ]; then
option="set"
fi
# ------------------------------- check tester ------------------------------- #
stdoption="std"
if [ "$option" != "" ]; then
stdoption="${option}-std"
fi
printf "${INFO}Checking for Tester Validity ...${EOL}"
printf "${PROMPT} make -s ${stdoption} ${EOL}"
make -s ${stdoption} > /dev/null
printf "${PROMPT} ./std_test > $stdfile${EOL}"
./std_test > $stdfile
if [ $? == 1 ] ; then
cat $stdfile
printf "\n"
printf "${ERROR} : Tester does not return 100%% for STD${EOL}"
exit
fi
printf "${OK} : Tester returns 100%% for STD${EOL}"
printf "\n"
# --------------------------------- run test --------------------------------- #
test_name=$option
if [ "$option" == "" ]; then
option="ft"
test_name="run"
fi
printf "${INFO}Runnning Tester ...${EOL}"
printf "${PROMPT} make -s ${option} ${EOL}"
make ${option} > /dev/null
./${test_name}_test 2>> $logfile
printf "See ./$logfile for more details ...${EOL}"
rm $stdfile