forked from cloudwan/gohan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_test.sh
executable file
·45 lines (37 loc) · 1.19 KB
/
run_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
#!/bin/bash
# Run Unit Test for mysql
if [[ $MYSQL_TEST == "true" ]]; then
# set MYSQL_TEST true if you want to run test against Mysql.
# you need running mysql on local without root password for testing.
mysql -uroot -e "drop database if exists gohan_test; create database gohan_test;"
fi
DATA_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
etcd -data-dir $DATA_DIR &
ETCD_PID=$!
if [[ $ENABLE_V8 == "true" ]]; then
TAGS="-tags v8"
fi
# Run test coverage on each subdirectories and merge the coverage profile.
echo "mode: count" > profile.cov
# Standard go tooling behavior is to ignore dirs with leading underscors
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d);
do
result=0
if ls $dir/*.go &> /dev/null; then
go test $TAGS -covermode=count -coverprofile=$dir/profile.tmp $dir --ginkgo.randomizeAllSpecs --ginkgo.failOnPending --ginkgo.trace --ginkgo.progress
result=$?
if [ -f $dir/profile.tmp ]
then
cat $dir/profile.tmp | tail -n +2 >> profile.cov
rm $dir/profile.tmp
fi
if [ $result -ne 0 ]; then
break
fi
fi
done
if [ $result -eq 0 ]; then
go tool cover -func profile.cov
fi
kill $ETCD_PID
exit $result