-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·103 lines (89 loc) · 5.67 KB
/
test.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# If save is provided, (like `./test.sh save`) the test runner will automatically save the results
# into a .txt file and make sure the tests runs. This helps to make sure I have updated tests when needed.
SKC_EXEC="./bin/skc"
FAIL=0
SUCCESS=0
TOTAL=0
RED="\033[31m"
GREEN="\033[32m"
RESET="\033[0m"
PURPLE="\033[35m"
BOLD="\033[1m"
ERRORS=""
echo -e $RED
echo -e '┏━ The Stańczyk Programming Language ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ ¿«fº"└└-.`└└*∞▄_ ╓▄∞╙╙└└└╙╙*▄▄ ┃
┃ J^. ,▄▄▄▄▄▄_ └▀████▄ç JA▀ └▀v ┃
┃ ,┘ ▄████████████▄¿ ▀██████▄▀└ ╓▄██████▄¿ "▄_ ┃
┃ ,─╓██▀└└└╙▀█████████ ▀████╘ ▄████████████_`██▄ ┃
┃ ;"▄█└ ,██████████- ▐█▀ ▄███████▀▀J█████▄▐▀██▄ ┃
┃ ▌█▀ _▄█▀▀█████████ █ ▄██████▌▄▀╙ ▀█▐▄,▀██▄ ┃
┃ ▐▄▀ A└-▀▌ █████████ ║ J███████▀ ▐▌▌╙█µ▀█▄ ┃
┃ A╙└▀█∩ [ █ █████████ ▌ ███████H J██ç ▀▄╙█_ ┃
┃ █ ▐▌ ▀▄▄▀ J█████████ H ████████ █ █ ▀▄▌ ┃
┃ ▀▄▄█▀. █████████▌ ████████ █ç__▄▀ ╓▀└╙%_┃
┃ ▐█████████ ▐ J████████▌ .└╙ █¿ ,▌┃
┃ █████████▀╙╙█▌└▐█╙└██▀▀████████ ╙▀▀▀ ┃
┃ ▐██▀┘Å▀▄A └▓█╓▐█▄▄██▄J▀@└▐▄Å▌▀██▌ ┃
┃ █▄▌▄█M╨╙└└- .└└▀**▀█▄,▌ ┃
┃ ²▀█▄▄L_ _J▄▄▄█▀└ ┃
┃ └╙▀▀▀▀▀MMMR████▀▀▀▀▀▀▀└ ┃
┃ ┃
┃ ┃
┃ ███████╗████████╗ █████╗ ███╗ ██╗ ██████╗███████╗██╗ ██╗██╗ ██╗ ┃
┃ ██╔════╝╚══██╔══╝██╔══██╗████╗ ██║██╔════╝╚══███╔╝╚██╗ ██╔╝██║ ██╔╝ ┃
┃ ███████╗ ██║ ███████║██╔██╗ ██║██║ ███╔╝ ╚████╔╝ █████╔╝ ┃
┃ ╚════██║ ██║ ██╔══██║██║╚██╗██║██║ ███╔╝ ╚██╔╝ ██╔═██╗ ┃
┃ ███████║ ██║ ██║ ██║██║ ╚████║╚██████╗███████╗ ██║ ██║ ██╗ ┃
┃ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ┃
┃ ┃'
echo -ne $RESET
for FILE in tests/*.sk; do
if [ -f "$FILE" ]; then
TOTAL=$(($TOTAL + 1))
TEST_SRC="${FILE%.*}"
TEST_NAME="${TEST_SRC##*/}"
if [ "$1" == "save" ]; then
${SKC_EXEC} build ${TEST_SRC}.sk -clean -silent
./output > ${TEST_SRC}.txt
fi
${SKC_EXEC} build ${TEST_SRC}.sk -clean -silent
./output > result.txt
RESULT=$(diff ${TEST_SRC}.txt result.txt)
echo -en $RED'┃'
printf "${RESET}${BOLD} ¤ %-56s${RESET}" $TEST_NAME
if [ -z "$RESULT" ]; then
echo -ne "${GREEN}✔ success${RESET}"
SUCCESS=$(($SUCCESS + 1))
else
echo -ne "${RED}✗ fail${RESET} "
FAIL=$(($FAIL + 1))
if [ "$1" == "show" ]; then
ERRORS+="${BOLD} ¤ ${TEST_NAME}.sk${RESET}\n\t- ${RESULT}\n"
fi
fi
echo -e $RED' ┃'
rm result.txt
rm output
fi
done
RCOLOR=""
if [[ "$FAIL" -gt 0 ]]; then
RCOLOR="$RED"
else
RCOLOR="$GREEN"
fi
echo -e $RED'┃ ┃
┃ ┃'
printf "${RED}┃${RESET} ${RCOLOR}${BOLD}TOTAL %2d :: Success %2d | Fails %2d${RESET}" $TOTAL $SUCCESS $FAIL
echo -e $RED' ┃'
echo -e $RED'┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ The Stańczyk Programming Language ━┛'
if [ "$1" == "show" ]; then
echo -e "${RESET}"
echo -e "Errors:"
echo -e "${ERRORS}"
fi
exit $FAIL