Skip to content

Commit

Permalink
Quickfix: Travis should fail if one of the tests failed (#98)
Browse files Browse the repository at this point in the history
resolves #96
  • Loading branch information
liamsi authored Sep 30, 2016
1 parent c28fa46 commit a5d0021
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@
# by Wáng Hǎiliàng
DIR_SOURCE="$(find . -maxdepth 10 -type f -not -path '*/vendor*' -name '*.go' | xargs -I {} dirname {} | sort | uniq)"


# If you want to test in combination with the -race flag on you have to use the atomic mode:
# echo "mode: atomic" > profile.cov
echo "mode: count" > profile.cov

all_tests_passed=true
# Run test coverage on each subdirectories and merge the coverage profile
for dir in ${DIR_SOURCE};
do
# change to -covermode=atomic if you want to run in combination with -race:
go test -covermode=count -coverprofile=$dir/profile.tmp $dir
if [ $? -ne 0 ]; then
all_tests_passed=false
fi
if [ -f $dir/profile.tmp ]
then
cat $dir/profile.tmp | tail -n +2 >> profile.cov
rm $dir/profile.tmp
fi
done
done

if [[ $all_tests_passed = true ]]; then
exit 0;
else
exit 1;
fi

0 comments on commit a5d0021

Please sign in to comment.