42sh/check_flemme.sh

47 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# build_and_test.sh - Automates build and test for 42sh with pretty output
set -e
# Colors
GREEN="\033[1;32m"
RED="\033[1;31m"
YELLOW="\033[1;33m"
RESET="\033[0m"
VERBOSE=0
if [[ "$1" == "--verbose" ]]; then
VERBOSE=1
fi
run_cmd() {
local desc="$1"
shift
if [[ $VERBOSE -eq 1 ]]; then
echo -e "${YELLOW}${desc}...${RESET}"
"$@"
else
echo -ne "${YELLOW}${desc}...${RESET}"
"$@" &> /dev/null && echo -e " ${GREEN}done${RESET}" || { echo -e " ${RED}failed${RESET}"; exit 1; }
fi
}
run_cmd "Running autoreconf" autoreconf --force --verbose --install
if [[ "$(uname)" == "Darwin" ]]; then
run_cmd "Configuring for MacOS" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -I/opt/homebrew/include' LDFLAGS='-L/opt/homebrew/lib'
else
run_cmd "Configuring for Linux" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -g -fsanitize=address'
fi
run_cmd "Cleaning build" make clean
if [[ $VERBOSE -eq 1 ]]; then
echo -e "${YELLOW}Running tests...${RESET}"
make check
else
echo -ne "${YELLOW}Running tests...${RESET}"
echo
make check
fi