Created
May 8, 2014 06:14
-
-
Save ToQoz/7fd1fe3d3c224c194eea to your computer and use it in GitHub Desktop.
golangでサブディレクトリのパッケージも含めたカバレッジをcoverallsに送るやつ
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/sh | |
COV_PARTIAL_FILE=profile.cov.out | |
COV_FILE=profile-all.cov.out | |
COV_MODE=count | |
HEADER="mode: $COV_MODE" | |
if which gxargs > /dev/null; then | |
XARGS=gxargs | |
else | |
XARGS=xargs | |
fi | |
XARGS_ARG=DIR | |
CMD_COV="go test $XARGS_ARG -covermode=$COV_MODE -coverprofile=$XARGS_ARG/$COV_PARTIAL_FILE" | |
CMD_CHECKDIR="ls $XARGS_ARG/$COV_PARTIAL_FILE > /dev/null 2>&1" | |
CMD_CONCATCOV="cat $XARGS_ARG/$COV_PARTIAL_FILE | grep -v '$HEADER' >> $COV_FILE" | |
GOVERALLS=$(echo $GOPATH | tr ':' '\n' | head -n 1)/bin/goveralls | |
echo $HEADER > $COV_FILE | |
find ./* -maxdepth 10 -name '*.go' -print0 | $XARGS -r0 -L1 dirname | uniq | $XARGS -I$XARGS_ARG sh -c "$CMD_COV && ($CMD_CHECKDIR && $CMD_CONCATCOV) || exit 0" | |
$GOVERALLS -coverprofile=$COV_FILE -service=travis-ci |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment