test
This commit is contained in:
53
run.sh
Executable file
53
run.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
echo -e "${YELLOW} ft_printf Test Compilation Script ${NC}"
|
||||
echo -e "${YELLOW}========================================${NC}"
|
||||
|
||||
# Build the library first
|
||||
echo -e "\n${YELLOW}[1/3] Building libftprintf.a...${NC}"
|
||||
make -s
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Error: Failed to build libftprintf.a${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}✓ Library built successfully${NC}"
|
||||
|
||||
# Compile main.c
|
||||
echo -e "\n${YELLOW}[2/3] Compiling main.c...${NC}"
|
||||
cc -Wall -Wextra -Werror -I. -Ilibft main.c -L. -lftprintf -Llibft -lft -o test_printf
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Error: Failed to compile main.c${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}✓ Test program compiled successfully${NC}"
|
||||
|
||||
# Run tests
|
||||
echo -e "\n${YELLOW}[3/3] Running tests...${NC}"
|
||||
echo -e "${YELLOW}========================================${NC}\n"
|
||||
./test_printf
|
||||
exit_code=$?
|
||||
|
||||
# Cleanup option
|
||||
echo -e "\n${YELLOW}========================================${NC}"
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
echo -e "${GREEN}All tests passed!${NC}"
|
||||
else
|
||||
echo -e "${RED}$exit_code test(s) failed!${NC}"
|
||||
fi
|
||||
|
||||
# Ask for cleanup
|
||||
read -p "Clean up test binary? [y/N] " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
rm -f test_printf
|
||||
echo -e "${GREEN}✓ Cleaned up${NC}"
|
||||
fi
|
||||
|
||||
exit $exit_code
|
||||
Reference in New Issue
Block a user