-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrademe.sh
More file actions
executable file
·299 lines (266 loc) · 10.3 KB
/
Copy pathgrademe.sh
File metadata and controls
executable file
·299 lines (266 loc) · 10.3 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#!/bin/bash
# **************************************************************************** #
# #
# This project is based on and inspired by the libft-war-machine version #
# maintained by @0x050f (https://github.com/0x050f/libft-war-machine), #
# which in turn was based on the versions by @lmartin and the original #
# Libftest by @jtoty. #
# #
# Modified and enhanced for the "Libft God" version (2026 Edition). #
# #
# **************************************************************************** #
#PATH_TEST=$(dirname $(readlink -f $0))
PATH_TEST="$(cd "$(dirname "$0")" && pwd -P)"
#exec 6>&2 2>/dev/null
exec 2> /dev/null
source "${PATH_TEST}"/srcs/variables.sh
source "${PATH_TEST}"/srcs/about.sh
IS_SINGLE_FUNCTION=0
for arg in ${@}
do
case "${arg}" in
"--help") man "${PATH_TEST}"/srcs/help.1
exit ;;
"-h") man "${PATH_TEST}"/srcs/help.1
exit ;;
"--about") display_about
exit ;;
"-a") display_about
exit ;;
"-d") DIRECTORY=1 ;;
"-s") OPT_NO_SEARCH=1 ;;
"-c") OPT_NO_COLOR=1 ;;
"-f") OPT_NO_FORBIDDEN=1 ;;
"-n") OPT_NO_NORMINETTE=1 ;;
"-u") OPT_NO_UPDATE=1 ;;
"-fast") OPT_FAST=1 ;;
"-doom" | "-hardcore") OPT_DOOM=1
OPT_NO_PART1=0
OPT_NO_PART2=0
OPT_NO_PART3=0
CHECK_IN_PART1=0
CHECK_IN_PART2=0
CHECK_IN_PART3=0 ;;
"-mandatory" | "-op1") OPT_NO_PART1=0
OPT_NO_PART2=1
OPT_NO_PART3=1
CHECK_IN_PART1=0
CHECK_IN_PART2=0
CHECK_IN_PART3=0 ;;
"-bonus" | "-op2") OPT_NO_PART1=1
OPT_NO_PART2=0
OPT_NO_PART3=1
CHECK_IN_PART2=0
CHECK_IN_PART1=0
CHECK_IN_PART3=0 ;;
"-stress" | "-op3") OPT_NO_PART1=1
OPT_NO_PART2=1
OPT_NO_PART3=0
CHECK_IN_PART3=0
CHECK_IN_PART2=0
CHECK_IN_PART1=0 ;;
"-p1") OPT_NO_PART1=1
CHECK_IN_PART1=0 ;;
"-p2") OPT_NO_PART2=1
CHECK_IN_PART2=0 ;;
"-p3") OPT_NO_PART3=1
CHECK_IN_PART3=0 ;;
*get_next_line*) IS_SINGLE_FUNCTION=1
for part in ${tab_all_part[*]}
do
check_part=$(echo CHECK_IN_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
if [ ${!check_part} -eq 1 ]
then
opt_part_var=$(echo OPT_NO_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
eval "${opt_part_var}=1"
p=0
activate_part=$(echo ACTIVATE_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
tab_part=$(echo ${part}[*])
nb_func=$(echo ${!tab_part} | wc -w)
while (( p < ${nb_func} ))
do
func_name=$(echo ${part}[$p])
if [ "$(echo ${arg} | sed 's/_bonus//g' | grep -ow $(echo ${!func_name} | cut -d . -f 1 | sed 's/_bonus//g'))" != "" ]
then
(( ${part}_activation[$p]=1 ))
(( ${activate_part}=1 ))
break
fi
(( p += 1 ))
done
fi
done ;;
esac
done
source "${PATH_TEST}"/srcs/colors.sh
source "${PATH_TEST}"/srcs/check_cheat.sh
source "${PATH_TEST}"/srcs/check_compilation.sh
source "${PATH_TEST}"/srcs/check_file.sh
source "${PATH_TEST}"/srcs/check_norme.sh
source "${PATH_TEST}"/srcs/diff_test.sh
source "${PATH_TEST}"/srcs/test_function.sh
source "${PATH_TEST}"/srcs/check_update.sh
cd "${PATH_TEST}"
if [ ${OPT_NO_UPDATE} -eq 0 ]
then
func_check_update
fi
if [ ! -e "${PATH_TEST}"/my_config.sh ]
then
printf "${BOLD}my_config.sh${DEFAULT} file is not found.\n"
printf "Creating file...\n"
if [ -e "${PATH_TEST}"/srcs/config_template.sh ]
then
cp "${PATH_TEST}"/srcs/config_template.sh "${PATH_TEST}"/my_config.sh
printf "File created with success in ${BOLD}${PURPLE}${PATH_TEST}\n${DEFAULT}"
if [ -f "${PATH_TEST}/../get_next_line.c" ] || [ -f "${PATH_TEST}/../get_next_line_bonus.c" ]; then
printf "Auto-detected GNL project in parent directory. Continuing...\n"
elif [ -f "${PATH_TEST}/../GNL/get_next_line.c" ] || [ -f "${PATH_TEST}/../GNL/get_next_line_bonus.c" ]; then
printf "Auto-detected GNL project in sibling directory (GNL). Continuing...\n"
else
printf "${RED}${UNDERLINE}Edit my_config.sh file${DEFAULT} with the path of your GNL project and launch script.\n"
exit
fi
else
printf "Can't create my_config.sh file, try to update or clone again the repository and retry.\n"
exit
fi
fi
source "${PATH_TEST}"/my_config.sh
if [ ${CUSTOM_DIRECTORY} -eq 1 ]
then
if [ -d "${PATH_TEST}"/dirlibft ]
then
rm -rf "${PATH_TEST}"/dirlibft
fi
printf "Copying files...\nPlease wait a moment.\n"
mkdir "${PATH_TEST}"/dirlibft
mkdir "${PATH_TEST}"/dirlibft/${SRC_DIR}
mkdir "${PATH_TEST}"/dirlibft/${HEADER_DIR}
cp "${PATH_LIBFT}"/* "${PATH_TEST}"/dirlibft
cp "${PATH_LIBFT}"/${SRC_DIR}/*.c "${PATH_TEST}"/dirlibft/${SRC_DIR}
cp "${PATH_LIBFT}"/${HEADER_DIR}/*.h "${PATH_TEST}"/dirlibft/${HEADER_DIR}
#find ${PATH_LIBFT} -type f -name "*.[ch]" -print | xargs cp -t ${PATH_TEST}/dirlibft
PATH_LIBFT="${PATH_TEST}"/dirlibft
# sleep 1000
fi
for part in ${tab_all_part[*]}
do
opt_part=$(echo OPT_NO_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
if [ ${!opt_part} -eq 0 ]
then
p=0
tab_part=$(echo ${part}[*])
nb_func=$(echo ${!tab_part} | wc -w)
while (( p < ${nb_func} ))
do
(( ${part}_activation[$p]=1 ))
(( p += 1 ))
done
fi
done
init_deepthought()
{
if [ -e "${PATH_DEEPTHOUGHT}"/deepthought ]
then
rm -f "${PATH_DEEPTHOUGHT}"/deepthought
fi
text="= Host-specific information "
printf "${text}" >> "${PATH_DEEPTHOUGHT}"/deepthought
printf "%.s=" $(seq 1 $(( 80 - ${#text} ))) >> "${PATH_DEEPTHOUGHT}"/deepthought
printf "\n$> hostname; uname -msr\n" >> "${PATH_DEEPTHOUGHT}"/deepthought
hostname >> "${PATH_DEEPTHOUGHT}"/deepthought
uname -msr >> "${PATH_DEEPTHOUGHT}"/deepthought
printf "$> date\n" >> "${PATH_DEEPTHOUGHT}"/deepthought
date >> "${PATH_DEEPTHOUGHT}"/deepthought
printf "$> cc --version\n" >> "${PATH_DEEPTHOUGHT}"/deepthought
cc --version >> "${PATH_DEEPTHOUGHT}"/deepthought
}
clear
init_deepthought
# Header Moderno
printf "${COLOR_TITLE}╔════════════════════──────────────────────────────────────────════════════════════╗${DEFAULT}\n"
printf "${COLOR_TITLE}║ ║${DEFAULT}\n"
if [ "${OPT_DOOM}" == "1" ]
then
printf "${COLOR_TITLE}║ GNL - GOD TESTER (DOOM MODE) ║${DEFAULT}\n"
else
printf "${COLOR_TITLE}║ GNL - GOD TESTER (VERSION 2026) ║${DEFAULT}\n"
fi
printf "${COLOR_TITLE}║ ║${DEFAULT}\n"
printf "${COLOR_TITLE}╚════════════════════──────────────────────────────────────────════════════════════╝${DEFAULT}\n"
if [ ${OPT_NO_SEARCH} -eq 0 ]
then
if [ ${IS_SINGLE_FUNCTION} -eq 0 ]
then
func_check_file
fi
fi
for part in ${tab_all_part[*]}
do
opt_part=$(echo OPT_NO_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
activate_part=$(echo ACTIVATE_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
if [ ${!opt_part} -eq 0 ]
then
(( ${activate_part}=1 ))
p=0
tab_part=$(echo ${part}[*])
nb_func=$(echo ${!tab_part} | wc -w)
while (( p < ${nb_func} ))
do
(( ${part}_activation[$p]=1 ))
(( p += 1 ))
done
fi
done
# Calcular total de funções para o estilo progressivo
GLOBAL_TOTAL=0
GLOBAL_CURRENT=0
for part in ${tab_all_part[*]}
do
activate_part=$(echo ACTIVATE_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
if [ ${!activate_part} -eq 1 ]
then
activation_tab=$(echo ${part}_activation[*])
for act in ${!activation_tab}
do
if [ $act -eq 1 ]
then
let "GLOBAL_TOTAL += 1"
fi
done
fi
done
for part in ${tab_all_part[*]}
do
activate_part=$(echo ACTIVATE_${part} | tr '[:lower:]' '[:upper:]' | rev | cut -c 6- | rev)
if [ ${!activate_part} -eq 1 ]
then
text="= ${part}tions "
printf "\n${text}" >> "${PATH_DEEPTHOUGHT}"/deepthought
printf "%.s=" $(seq 1 $(( 80 - ${#text} ))) >> "${PATH_DEEPTHOUGHT}"/deepthought
printf "\n" >> "${PATH_DEEPTHOUGHT}"/deepthought
test_function $(echo ${part}[*])
fi
done
if [ -e "${PATH_TEST}"/user_exe ]
then
rm "${PATH_TEST}"/user_exe
fi
if [ ${DIRECTORY} -eq 1 ]
then
if [ -d "${PATH_TEST}"/dirlibft ]
then
rm -rf "${PATH_TEST}"/dirlibft
fi
fi
if [ ${ACTIVATE_PART1} -eq 1 ] || [ ${ACTIVATE_PART2} -eq 1 ] || [ ${ACTIVATE_PART3} -eq 1 ]
then
printf "Abort : ${RED}A${DEFAULT} Bus error : ${RED}B${DEFAULT} Segmentation fault : ${RED}S${DEFAULT} Timeout : ${RED}T${DEFAULT} Nothing turned in : ${RED}NTI${DEFAULT}\n"
printf "\n"
fi
printf "A deepthought file has been generated in ${COLOR_DEEPTHOUGHT_PATH}\"${PATH_DEEPTHOUGHT}\"\n\n${DEFAULT}"
# make --no-print-directory -C "${PATH_LIBFT}" fclean > /dev/null
# nuke_it_all
find "${PATH_TEST}" -name 'user_output_test*' -delete
rm -rf "${PATH_TEST}"/dirlibft/