Skip to content

Commit

Permalink
Merge pull request #125 from seungsoo-lee/master
Browse files Browse the repository at this point in the history
Update code coverage
  • Loading branch information
seungsoo-lee committed Mar 19, 2021
2 parents 343cee5 + 3b10b16 commit 39c5215
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/test-code-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
NC='\033[0m'

AUTOPOL_HOME=`dirname $(realpath "$0")`/..
TEST_HOME=`dirname $(realpath "$0")`

## ============== ##
## == Database == ##
## ============== ##

function start_and_wait_for_mysql_initialization() {
cd $TEST_HOME/mysql
docker-compose up -d

for (( ; ; ))
do
docker logs mysql-example > ./logs 2>&1
log=$(cat $TEST_HOME/mysql/logs)
if [[ $log == *"Ready for start up"* ]]; then
break
fi

sleep 1
done
}

function stop_and_wait_for_mysql_termination() {
cd $TEST_HOME/mysql
docker-compose down -v
rm $TEST_HOME/mysql/logs
}

## Step 1. Start MySQL database

echo -e "${ORANGE}[INFO] Starting MySQL database${NC}"
start_and_wait_for_mysql_initialization
echo "[INFO] Started MySQL database"

## Step 2. Test coverage

t="/tmp/go-cover.$$.tmp"
cd $AUTOPOL_HOME/src/core; go clean -testcache .; go test -coverprofile=$t $@ && go tool cover -html=$t && unlink $t
cd $AUTOPOL_HOME/src/libs; go clean -testcache .; go test -coverprofile=$t $@ && go tool cover -html=$t && unlink $t
cd $AUTOPOL_HOME/src/plugin; go clean -testcache .; go test -coverprofile=$t $@ && go tool cover -html=$t && unlink $t
cd $AUTOPOL_HOME/src/server; go clean -testcache .; go test -coverprofile=$t $@ && go tool cover -html=$t && unlink $t

if [ $? != 0 ]; then
echo
echo "[FAIL] No Coverage"
exit 1
fi

echo
echo "[PASS] Coverage Generated"

## Step 3. Stop MySQL Database

echo -e "${ORANGE}[INFO] Stopping MySQL database${NC}"
stop_and_wait_for_mysql_termination
echo "[INFO] Stopped MySQL database"

0 comments on commit 39c5215

Please sign in to comment.