#!/bin/bash # Test Tool # # The Translators - Spring 2025 # RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' LIGHTGRAY='\033[0;37m' DARKGRAY='\033[1;30m' LIGHTRED='\033[1;31m' LIGHTGREEN='\033[1;32m' YELLOW='\033[1;33m' LIGHTBLUE='\033[1;34m' LIGHTPURPLE='\033[1;35m' LIGHTCYAN='\033[1;36m' WHITE='\033[1;37m' if [ ! -f "./alpha" ]; then echo -e "${RED}[ERROR] ${YELLOW}File ./alpha not found!${WHITE}" exit 1 fi if [ ! -d "./out" ]; then mkdir -p out fi SWITCH=${YELLOW} count=0 switchfunc() { if [ $count -eq 0 ]; then count=1 SWITCH=${YELLOW} else count=0 SWITCH='\033[0;35m' fi } if [ $# -eq 0 ]; then echo -e "${YELLOW}[INFO] ${WHITE}Running all tests...${WHITE}" echo -e "${YELLOW}[INFO] ${ORANGE}Testing SPRINT-1 ---------------------------\n${WHITE}" for file in ./tests/sprint1/test/*; do if [ -f "$file" ]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n" switchfunc fi done echo -e "" echo -e "${YELLOW}[INFO] ${ORANGE}Testing SPRINT-2 ---------------------------\n${WHITE}" for file in ./tests/sprint2/test/*; do if [ -f "$file" ]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n" switchfunc fi done echo -e "" echo -e "${YELLOW}[INFO] ${ORANGE}Testing SPRINT-3 ---------------------------\n${WHITE}" for file in ./tests/sprint3/test/*; do if [ -f "$file" ]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n" switchfunc fi done echo -e "" echo -e "${YELLOW}[INFO] ${ORANGE}Testing SPRINT-4 ---------------------------\n${WHITE}" for file in ./tests/sprint4/test/*; do if [ -f "$file" ]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n${WHITE}" switchfunc fi done else if [ "$1" == "--help" ]; then echo -e "${YELLOW}[INFO] ${WHITE}Usage: ./test.sh [prefix]" echo -e "${YELLOW}[INFO] ${WHITE}--help: show this help message" echo -e "${YELLOW}[INFO] ${WHITE}--file : run test with file" exit 0 fi if [[ "$1" == "--file" ]]; then shift if [ $# -eq 0 ]; then echo -e "${RED}[ERROR] ${YELLOW}No file specified!${WHITE}" exit 1 fi if [ -f "$1" ]; then filename=$(basename -- "$1") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$1" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}" exit 1 else echo -e "${RED}[ERROR] ${YELLOW}File $1 not found!${WHITE}" exit 1 fi fi if [[ "$1" == "sp1" ]]; then echo -e "${YELLOW}[INFO] ${WHITE}Running tests with prefix $1..." for file in ./tests/sprint1/test/*; do if [[ "$file" == *"$1"* ]]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n" switchfunc fi done elif [[ "$1" == "sp2" ]]; then echo -e "${YELLOW}[INFO] ${WHITE}Running tests with prefix $1..." for file in ./tests/sprint2/test/*; do if [[ "$file" == *"$1"* ]]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n" switchfunc fi done elif [[ "$1" == "sp3" ]]; then echo -e "${YELLOW}[INFO] ${WHITE}Running tests with prefix $1..." for file in ./tests/sprint3/test/*; do if [[ "$file" == *"$1"* ]]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n" switchfunc fi done elif [[ "$1" == "sp4" ]]; then echo -e "${YELLOW}[INFO] ${WHITE}Running tests with prefix $1..." for file in ./tests/sprint4/test/*; do if [[ "$file" == *"$1"* ]]; then filename=$(basename -- "$file") echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}" ./alpha -st -debug "$file" echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n" switchfunc fi done else echo -e "${RED}[ERROR] ${YELLOW}Invalid prefix $1!${WHITE}" exit 1 fi fi