github.com/jbking/gohan@v0.0.0-20151217002006-b41ccf1c2a96/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 & 13 ETCD_PID=$! 14 15 if [[ $ENABLE_V8 == "true" ]]; then 16 TAGS="-tags v8" 17 fi 18 19 # Run test coverage on each subdirectories and merge the coverage profile. 20 echo "mode: count" > profile.cov 21 22 # Standard go tooling behavior is to ignore dirs with leading underscors 23 for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -type d); 24 do 25 result=0 26 if ls $dir/*.go &> /dev/null; then 27 go test $TAGS -covermode=count -coverprofile=$dir/profile.tmp $dir --ginkgo.randomizeAllSpecs --ginkgo.failOnPending --ginkgo.trace --ginkgo.progress 28 result=$? 29 if [ -f $dir/profile.tmp ] 30 then 31 cat $dir/profile.tmp | tail -n +2 >> profile.cov 32 rm $dir/profile.tmp 33 fi 34 if [ $result -ne 0 ]; then 35 break 36 fi 37 fi 38 done 39 40 if [ $result -eq 0 ]; then 41 go tool cover -func profile.cov 42 fi 43 44 kill $ETCD_PID 45 exit $result