This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_tests.sh
executable file
·90 lines (78 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
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
function green() {
printf "\e[32m"
echo "$1"
printf "\e[0m"
}
function red() {
printf "\e[31m"
echo "$1"
printf "\e[0m"
}
pushd lang/parsing > /dev/null
make clean
make
if [ $? -ne 0 ]; then
red "FAILED: make"
exit 1
else
green "PASS"
green "ok make"
fi
popd > /dev/null
go build
if [ $? -ne 0 ]; then
red "FAILED: build"
exit 1
else
green "PASS"
green "ok build"
fi
testdirs=$(find . -type f -name "*\_test.go" | grep -v "\.gondler" | sed -e "s/[^\/]*$//" | uniq)
for testdir in $testdirs; do
pushd $testdir > /dev/null
if result=$(go test); then
printf "\e[32m${result}\e[0m\n"
else
printf "\e[31m${result}\e[0m\n"
exit 1
fi
popd > /dev/null
done
tempfile=`mktemp /tmp/tmp.XXXXXXXXXX`
trap "rm $tempfile" 0
for filename in `find test -type f -name '*.sandal'`; do
case $filename in
(*.sandal)
actual_filename="${filename}"
expect_filename="${filename%.sandal}.smv"
if [ -e $expect_filename ]; then
err_output=`./sandal ${actual_filename} 2>&1 1>$tempfile`
if [ $? -ne 0 ]; then
red "FAILED: ${actual_filename}"
red " ${err_output}"
exit 1
else
diff_output=`diff -u $expect_filename $tempfile`
if [ $? -ne 0 ]; then
red "FAILED: ${actual_filename}"
red "${diff_output}" | awk '{ print " " $0 }'
exit 1
else
green "PASS"
green "ok ${actual_filename} -> ${expect_filename}"
fi
fi
else
err_output=`./sandal ${actual_filename} 2>&1 1>$tempfile`
if [ $? -ne 0 ]; then
red "FAILED: ${actual_filename}"
red " ${err_output}"
exit 1
else
green "PASS"
green "ok ${actual_filename}"
fi
fi
esac
done