@@ -106,6 +106,10 @@ Compiles ${CYAN}${SRC}/main.c${CLEAR} & all files in ${CYAN}${DIR}/${CLEAR}.
106
106
${RED} -l${CLEAR} | ${RED} --link${CLEAR}
107
107
Links all the files in ${CYAN}${OUT} /${CLEAR} to an executable with ${BLUE} {EXECUTABLE_NA}ME}${CLEAR}
108
108
109
+ ${RED} -st${CLEAR} | ${RED} --setup-testing${CLEAR}
110
+ Sets up and installs unity in the correct path.
111
+ (Automatically runs if not already installed during --test)
112
+
109
113
${RED} -t${CLEAR} | ${RED} --test${CLEAR}
110
114
Runs unit tests in ${TEST}
111
115
@@ -194,17 +198,34 @@ link() {
194
198
echo -ne " ${YELLOW} !${CLEAR} ${CYAN}${EXECUTABLE_NAME}${CLEAR} seems to already exist, you wanna relink it? [${GREEN} Y${CLEAR} /${RED} n${CLEAR} ]: "
195
199
read -r RELINK
196
200
if [[ ! ${RELINK} =~ [Nn] ]]; then
201
+ # shellcheck disable=SC2086,SC2048
197
202
" ${CC} " -fuse-ld=mold ${CFLAGS} ${LINKER_FLAGS} -o " ${BIN} /${EXECUTABLE_NAME} " ${TRIMMED_FILES[*]}
198
203
echo -e " ${GREEN} ✓${CLEAR} Linked ${CYAN}${TRIMMED_FILES}${CLEAR} successfully"
199
204
fi
200
205
else
206
+ # shellcheck disable=SC2086,SC2048
201
207
" ${CC} " -fuse-ld=mold ${CFLAGS} ${LINKER_FLAGS} -o " ${BIN} /${EXECUTABLE_NAME} " ${TRIMMED_FILES[*]}
202
208
echo -e " ${GREEN} ✓${CLEAR} Linked ${CYAN}${TRIMMED_FILES}${CLEAR} successfully"
203
209
fi
204
210
205
211
popd > /dev/null || handle_failure " Failed to popd" # || echo "Failed to popd" && exit 1
206
212
}
207
213
214
+ setup_unity () {
215
+ mkdir " ${TEST} /unity"
216
+ mkdir temp_dir
217
+
218
+ pushd temp_dir > /dev/null || handle_failure " Failed to pushd"
219
+ git clone https://github.com/ThrowTheSwitch/Unity
220
+
221
+ rm Unity/src/meson.build
222
+ mv Unity/src/* " ${TEST} /unity"
223
+
224
+ popd > /dev/null || handle_failure " Failed to popd"
225
+
226
+ rm -fr temp_dir
227
+ }
228
+
208
229
unit_test () {
209
230
local -a TESTS
210
231
local TEST_FILE
@@ -222,18 +243,7 @@ unit_test() {
222
243
local TRIMMED_BINARY_NAME
223
244
224
245
if [[ ! -d ${TEST} /unity ]]; then
225
- mkdir " ${TEST} /unity"
226
- mkdir temp_dir
227
-
228
- pushd temp_dir > /dev/null || handle_failure " Failed to pushd"
229
- git clone https://github.com/ThrowTheSwitch/Unity
230
-
231
- rm Unity/src/meson.build
232
- mv Unity/src/* " ${TEST} /unity"
233
-
234
- popd > /dev/null || handle_failure " Failed to popd"
235
-
236
- rm -fr temp_dir
246
+ setup_unity
237
247
fi
238
248
239
249
if [[ ! -d ${TEST_OUT} ]]; then
@@ -283,6 +293,7 @@ unit_test() {
283
293
TRIMMED_TEST_OBJ_FILENAME=" ${TRIMMED_TEST_OBJ_FILE##*/ } "
284
294
285
295
echo -e " ${BLUE} >${CLEAR} Linking ${CYAN}${TRIMMED_TEST_FILENAME} .o${CLEAR} & ${CYAN} unity.o${CLEAR} to ${TRIMMED_TEST_OBJ_FILENAME} "
296
+ # shellcheck disable=SC2086,SC2048
286
297
" ${CC} " -fuse-ld=mold ${CFLAGS} ${LINKER_FLAGS} -o " ${TEST_BIN} /${TRIMMED_TEST_OBJ_FILENAME} " " ${TRIMMED_TEST_OBJ_FILENAME} .o" " ./deps/${TRIMMED_TEST_OBJ_FILENAME: 5} .o" " ${TEST_OUT} /unity/unity.o"
287
298
echo -e " ${GREEN} ✓${CLEAR} Successfully linked ${CYAN}${TRIMMED_TEST_FILENAME} .o${CLEAR} & ${CYAN} unity.o${CLEAR} to ${TRIMMED_TEST_OBJ_FILENAME} "
288
299
done
@@ -345,7 +356,7 @@ clean() {
345
356
LOCALBIN=${2}
346
357
CONFIRMATION=${3}
347
358
LOG=${4: true}
348
-
359
+
349
360
if ${LOG} ; then
350
361
echo -e " ${RED} !${CLEAR} Cleaning ${CYAN}${LOCALOUT}${CLEAR} & ${CYAN}${LOCALBIN}${CLEAR} ."
351
362
fi
@@ -395,6 +406,9 @@ case $1 in
395
406
clean_dangling " ${DIR} " " ${OUT} "
396
407
link " ${2} "
397
408
;;
409
+ " -st" | " --setup-testing" )
410
+ setup_unity
411
+ ;;
398
412
" -t" | " --test" )
399
413
unit_test
400
414
;;
0 commit comments