mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-05-14 19:29:32 +08:00
45 lines
1.2 KiB
Bash
Executable File
45 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
## Only uncomment the below for debugging
|
|
#set -euxo pipefail
|
|
|
|
LOCAL_GO_VERSION=$(go version | awk -F' ' '{print $3}' | tr -d '[:space:]')
|
|
GO_VERSION="${TRAVIS_GO_VERSION:=$LOCAL_GO_VERSION}"
|
|
TIP_VERSION_IDENTIFIER="tip"
|
|
echo $GO_VERSION
|
|
|
|
# Hold the package names that contain failures
|
|
FAIL_PACKAGES=()
|
|
|
|
pushd $PWD/..
|
|
# Set up coverage report file
|
|
COVERAGE_REPORT_LOCATION="./profile.cov"
|
|
echo "" > $COVERAGE_REPORT_LOCATION
|
|
|
|
# Exclude vendor in the same way as Makefile does
|
|
EXCLUDING_VENDOR=$(go list ./... | grep -v /vendor/)
|
|
|
|
# Iterate over all non-vendor packages and run tests with coverage
|
|
for package in $EXCLUDING_VENDOR; do \
|
|
if [ $GO_VERSION == $TIP_VERSION_IDENTIFIER ]; then
|
|
# `go test` runs a vet subset as of this Change https://go-review.googlesource.com/c/go/+/74356
|
|
result=$(go test -vet=off -covermode=count -coverprofile=tmp.cov $package)
|
|
else
|
|
result=$(go test -covermode=count -coverprofile=tmp.cov $package)
|
|
fi
|
|
if [ $? -ne 0 ]; then
|
|
FAIL_PACKAGES+=($package);
|
|
fi;
|
|
echo "$result"
|
|
if [ -f tmp.cov ]; then
|
|
cat tmp.cov >> profile.cov;
|
|
rm tmp.cov;
|
|
fi;
|
|
done
|
|
|
|
# exit 1 if there have been any test failures
|
|
if [ ${#FAIL_PACKAGES[@]} -ne 0 ]; then
|
|
exit 1
|
|
fi;
|
|
popd
|