-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtest.sh
executable file
·60 lines (44 loc) · 1.37 KB
/
runtest.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
52
53
54
55
56
57
58
59
60
#!/bin/bash
GRAY='\033[1;30m'; YELLOW='\033[1;33m'
BLUE='\033[0;34m'; NC='\033[0m'
BOLD='\e[1m'
SCRIPTPATH="$( cd "$(dirname "$0")/" >/dev/null 2>&1 ; pwd -P )"
stucked=()
total=0
selected_file=$1
test_files=$(find $(pwd) | grep "test.*.cpp" | grep -v ".w.$")
printf "" > test_output
for test in $test_files; do
total=$((total+1))
cd $(dirname ${test})
printf "> [ Run Test ${GRAY}${test}${NC} ]\n"
current_dict=$(cd -)
bname=$(basename ${test})
if [ "$bname" = "$selected_file" ]; then
g++ $bname -o ./$bname.out -I$SCRIPTPATH && ./$bname.out && rm ./$bname.out
return_code=$?
else
g++ $bname -o ./$bname.out -I$SCRIPTPATH && ./$bname.out >> $current_dict/test_output && rm ./$bname.out
return_code=$?
fi
cd $current_dict
if [[ $return_code -eq 0 ]]; then
printf "${BLUE}${BOLD}\n\t◁ PASS ✔ ▷\n\n${NC}"
else
printf "${YELLOW}${BOLD}\n\t◁ STUCK ✘ ▷\n\n${NC}"
stucked=( "${stucked[@]}" "$bname" )
fi
done
printf "\n${BLUE}${BOLD}⚠ Stucked: ${YELLOW}${#stucked[@]}${NC}/${BLUE}$total${NC}\n"
for file in ${stucked[@]}; do
printf "${YELLOW}\t➤ $file${NC}\n"
done
echo
while true; do
read -p "Do you wanna keep output of test processes? [Yy/Nn] " yn
case $yn in
[Yy]* ) exit;;
[Nn]* ) rm test_output; break;;
* ) echo "Please answer yes or no.";;
esac
done