Created
January 31, 2017 14:11
-
-
Save grodowski/d9d2d3cd2f45356d3405d05444b03f7a to your computer and use it in GitHub Desktop.
Golang - recursive tests + coverage
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 | |
shopt -s globstar | |
rootdir=`pwd` | |
for dir in **/ ; do | |
cd $dir | |
exec 5>&1 | |
out=$(go test -v -coverprofile=cov_part.out | tee >(cat - >&5)) | |
if [ $? -eq 1 ] ; then | |
if [ $(cat $out | grep -o 'no buildable Go source files') == "" ] ; then | |
echo "Tests failed! Exiting..." ; exit 1 | |
fi | |
fi | |
cd $rootdir | |
done | |
if [ -z "$CI_NAME" ]; then | |
echo "CI_NAME is unset. Skipping coverage report!" | |
exit 0 | |
fi | |
find . -name cov_part.out | xargs cat > cov.out | |
# make sure we do not run the ruby gem which is first in $PATH :( | |
node /usr/local/lib/node_modules/codeclimate-test-reporter/bin/codeclimate.js < cov.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment