Skip to content

Instantly share code, notes, and snippets.

@mitsuse
Created January 7, 2015 03:38
Show Gist options
  • Save mitsuse/ad857dbe59340f34d462 to your computer and use it in GitHub Desktop.
Save mitsuse/ad857dbe59340f34d462 to your computer and use it in GitHub Desktop.
Shell scripts to calculate test coverage in Golang
#!/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
#!/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