github.com/mmatczuk/gohan@v0.0.0-20170206152520-30e45d9bdb69/run_test.sh (about) 1 #!/bin/bash 2 3 # Run Unit Test for mysql 4 5 if [[ $MYSQL_TEST == "true" ]]; then 6 # set MYSQL_TEST true if you want to run test against Mysql. 7 # you need running mysql on local without root password for testing. 8 mysql -uroot -e "drop database if exists gohan_test; create database gohan_test;" 9 fi 10 11 DATA_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'` 12 etcd -data-dir $DATA_DIR --listen-peer-urls http://:2380 --listen-client-urls http://:2379 --advertise-client-urls http://127.0.0.1:2379 & 13 ETCD_PID=$! 14 15 echo "mode: count" > profile.cov 16 17 # Standard go tooling behavior is to ignore dirs with leading underscors 18 for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './vendor/*' -type d); 19 do 20 if ls $dir/*.go &> /dev/null; then 21 go test -race -covermode=atomic -coverprofile=$dir/profile.tmp $dir 22 result=$? 23 if [ -f $dir/profile.tmp ] 24 then 25 cat $dir/profile.tmp | tail -n +2 >> profile.cov 26 rm $dir/profile.tmp 27 fi 28 if [ $result -ne 0 ]; then 29 exit $result 30 fi 31 fi 32 done 33 34 go tool cover -func profile.cov 35 kill $ETCD_PID