-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_test.sh
executable file
·59 lines (50 loc) · 1.25 KB
/
do_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
#!/bin/bash
compilers=("gcc" "clang" "g++" "clang++" "musl-gcc")
compile_options=("" "-O0" "-O1" "-O2" "-O3" "-Og" "-Ofast" "-Os" "-Oz")
errored_cases=()
worked_cases=()
dir=$(cd "$(dirname "$0")" && pwd)
if ! type "diff" > /dev/null 2>&1; then
echo diff is not installed
exit 1
fi
for cc in "${compilers[@]}"; do
if ! type "$cc" > /dev/null 2>&1; then
echo -e "\e[1;93mWARNING: $cc is not installed. Skip tests!\e[0m"
continue
fi
for options in "${compile_options[@]}"; do
$cc main.c $options -o unsafebf 2>/dev/null
if [[ $? -ne 0 ]]; then
echo -e "\e[1;91mCOMPILE ERR\e[0m"
continue
fi
for f in "$dir"/tests/*.bf; do
echo "TEST : $cc $options"
echo "TESTCASE: $(basename "$f")"
echo -n "RESULT : "
diff <(./unsafebf "$(cat "$f")") <(echo 0) >/dev/null
if [[ $? -eq 0 ]]; then
echo -e "\e[1;92mOK\e[0m"
worked_cases+=("$cc $options $(basename "$f")")
else
echo -e "\e[1;91mERR\e[0m"
errored_cases+=("$cc $options $(basename "$f")")
fi
echo
done
done
done
if [[ ${#errored_cases[@]} -eq 0 ]]; then
echo yeah! worked in all cases!
else
echo Worked in:
for c in "${worked_cases[@]}"; do
echo "- $c"
done
echo
echo Errored in:
for c in "${errored_cases[@]}"; do
echo "- $c"
done
fi