Created
August 20, 2019 07:19
-
-
Save samaita/05c10333ba0bdb740f2c6f9ec3d0bf06 to your computer and use it in GitHub Desktop.
Bash Script for measure Unit Test coverage percentage for Golang package, skipping vendor
This file contains hidden or 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 | |
set -e | |
echo 'mode: count' > profile.cov | |
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path '*/vendor*' -type d); | |
do | |
if ls $dir/*.go &> /dev/null; then | |
go test -short -covermode=count -coverprofile=$dir/profile.tmp $dir | |
if [ -f $dir/profile.tmp ] | |
then | |
cat $dir/profile.tmp | tail -n +2 >> profile.cov | |
rm $dir/profile.tmp | |
fi | |
fi | |
done | |
go tool cover -func profile.cov |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding skipping vendor
Source:
https://stackoverflow.com/questions/33444968/how-to-get-all-packages-code-coverage-together-in-go