Created
January 7, 2015 03:38
-
-
Save mitsuse/ad857dbe59340f34d462 to your computer and use it in GitHub Desktop.
Shell scripts to calculate test coverage in Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
base_package=github.com/user_name/repo_name | |
base_path=${GOPATH}/src/${base_package} | |
package_list=( | |
${base_package} | |
) | |
if [ ! -d ${base_path}/coverprofile ] | |
then | |
mkdir ${base_path}/coverprofile | |
else | |
rm ${base_path}/coverprofile/*.coverprofile | |
fi | |
for package in ${package_list[@]} | |
do | |
cover_name=$(echo ${package} | sed -e "s/\//__/g").coverprofile | |
cover_path=${base_path}/coverprofile/${cover_name} | |
go test -covermode=count -coverprofile ${cover_path} ${package} | |
done | |
cd ${base_path}/coverprofile && gover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
profile=coverprofile/gover.coverprofile | |
service=circleci | |
token= | |
goveralls -coverprofile ${profile} -service ${service} -repotoken $token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment