-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgotest.sh
executable file
·51 lines (47 loc) · 1.87 KB
/
gotest.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
# **************************************************************************** #
# #
# :::::::: #
# gotest.sh :+: :+: #
# +:+ #
# By: mjiam <[email protected]> +#+ #
# +#+ #
# Created: 2022/06/22 16:23:32 by mjiam #+# #+# #
# Updated: 2022/10/12 14:48:23 by mjiam ######## odam.nl #
# #
# **************************************************************************** #
#!/usr/bin/env bash
# Colours
BOLD="\033[0;1m"
RED="\033[0;31m"
CYAN="\033[0;36m"
PURP="\033[0;35m"
GREEN="\033[0;32m"
BLUE="\033[0;34m"
BLUEBG="\033[44m"
WHITE="\033[1;97m"
RESET="\033[0m"
choose_test () {
printf "\n${CYAN}"
read -r -n 1 -p $'\nPress [1] for basic test output. Press [2] for visual test output.\n\n' choice
printf "${RESET}\n\n"
case $choice in
1)
cd build && ctest
;;
2)
cd build && ./$bin_name
;;
*) # any other input
exit 0
;;
esac
}
cmake .. -DBUILD_GMOCK=OFF -S . -B build
cmake --build build | tee -a build_out # output cmake build to stdout & also file
# grab last line starting with [100%] and greps only the binary name
bin_name=$(grep -E '^\[100%\]' build_out | tail -n 1 | grep -oE '[^ ]+$')
rm build_out
# rm -rf build/www/ # UNCOMMENT if file/html assets needed for test
# cp -r www build/ # UNCOMMENT if file/html assets needed for test
printf "${GREEN}\nPlease make sure necessary config files have been copied into this folder.${RESET}"
choose_test "$1"