-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.sh
executable file
·90 lines (79 loc) · 2.68 KB
/
run.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
#!/bin/bash
# **************************************************************************** #
# #
# :::::::: #
# run.sh :+: :+: #
# +:+ #
# By: peerdb <[email protected]> +#+ #
# +#+ #
# Created: 2020/09/09 16:47:13 by peerdb #+# #+# #
# Updated: 2020/10/21 00:01:45 by peerdb ######## odam.nl #
# #
# **************************************************************************** #
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
PURPLE='\033[0;35m'
LIGHTPURPLE='\033[1;35m'
CYAN='\033[0;36m'
LIGHTCYAN='\033[1;36m'
RESET='\033[0m'
function test {
for var in "$@"
do
if [[ $var == "debug" ]]; then
D="DEBUG=1"
elif [[ $var == "g++" || $var == "clang++" ]]; then
C="COMPILER=$var"
echo -e "${LIGHTPURPLE}COMPILER = $var ${RESET}"
echo -e "OSTYPE = $OSTYPE"
if [[ $OSTYPE == *"darwin"* && $var == "g++" ]]; then
C="COMPILER=$(brew --prefix)/bin/g++-10"
fi
elif [[ $var == "time" ]]; then
TIME=$var
elif [[ $var == "leaks" ]]; then
LEAKS=$var
fi
done
make fuckingclean
sed "s/ft::/std::/g" tests/"$1"_main.cpp > tests/"$1"_stdmain.cpp
echo -e "${RED}Compiling and testing for the STL version of the $1 container${RESET}"
make "$1" $C $D STD=1 && ./containers.out "$TIME" "$LEAKS" > tests/std.txt #2>&1
STATUS_STL=$?
echo -e "${GREEN}Compiling and testing for my FT version of the $1 container${RESET}"
make "$1" $C $D && ./containers.out "$TIME" "$LEAKS" > tests/ft.txt #2>&1
STATUS_FT=$?
# echo -e "${ORANGE}Startin testing for $1${RESET}"
echo -e "${PURPLE}STATUS_FT = ${STATUS_FT}, STATUS_STL = ${STATUS_STL}${RESET}"
if [[ $STATUS_FT -ne 0 || $STATUS_STL -ne 0 ]]; then
exit 1
fi
diff tests/ft.txt tests/std.txt > tests/diff.txt;
if [ $? -eq 1 ]; then
echo -e "${RED}Diff failed${RESET}"
cat tests/diff.txt
exit 1
else
echo -e "${LIGHTPURPLE}Diff found no differences${RESET}"
fi
}
declare -a arr=("list" "vector" "map" "stack" "queue" "deque" "set" "multiset" "multimap")
ARG="all"
for var in "$@"
do
for container in "${arr[@]}"
do
if [[ $var == "$container" ]]; then
ARG=$container
fi
done
done
if [[ $ARG == "all" ]]; then
for i in "${arr[@]}"
do
test "$i" "$1" "$2" "$3"
done
else
test "$ARG" "$2" "$3" "$4"
fi