-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.sh
executable file
·80 lines (63 loc) · 1.84 KB
/
run_tests.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env sh
# @author : Luis Miguel Baez <[email protected]>
# Shell Colors
reset="\033[0m";
red_fill="\033[7;107;91m";
red_bold="\033[1;31m";
blue_fill="\033[7;49;34m";
blue_bold="\033[49;34m";
green_fill="\033[7;49;32m";
green_bold="\033[49;32m";
yellow_fill="\033[7;49;33m";
yellow_bold="\033[49;33m";
white_fill="\033[7;49;20m";
white_bold="\033[49;20m";
# Flags
isLocal="local"
for arg in "$@"
do
if [ "$arg" = "--judge" ]; then
isLocal="judge"
fi
done
# check if it is current directory
if [ "$1" = "--current-dir" ]; then
path=""
else
cd "$1"
path=$1
fi
# Delete binaries
rm -f "$2.o"
# Username
echo "\n📌 ${red_bold}@SorKierkegaard${reset}\n"
# C++ Compiler
if [ "$isLocal" = "local" ]; then
g++ -std=c++17 -Wextra -O2 -DLOCAL=1 -o "$2.o" "$2.cpp"
elif [ "$isLocal" = "judge" ]; then
g++ -std=c++17 -DONLINE_JUDGE=1 -o "$2.o" "$2.cpp"
fi
# Execute all testcases
for i in *.in; do
[ -f "$i" ] || break
# Show testcase filename
echo "🔴 ${yellow_fill}File '$i'${reset}"
# Time Elapsed
START_TIME=$(date +%s%N);
echo "-$white_fill"
# Execute Testcase
timeout 3s ./$2.o < $i > my${i%%.in}.out
END_TIME=$((($(date +%s%N) - $START_TIME)/1000000));
# Show testcase output
cat my${i%%.in}.out
echo "$reset-"
# Check TLE and Show execution time
if [ "$END_TIME" -lt 2000 ]; then
echo "🌀 ${green_fill}Finished in : ${reset}${yellow_fill}$END_TIME${reset}${green_fill} ms$reset"
else
echo "⛔ ${red_fill}Time Limit Exceeded : ${reset}${yellow_fill}$END_TIME${reset}${red_fill} ms$reset"
fi
echo ""
echo "${green_bold}≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡${reset}"
echo ""
done