2015-04-11 13:21:56 -07:00
|
|
|
#!/usr/bin/env bash
|
2016-11-02 17:27:49 -07:00
|
|
|
set -e
|
2016-02-12 16:50:37 -08:00
|
|
|
|
2017-03-23 19:14:38 -04:00
|
|
|
if [ -n "$TRAVIS" ]; then
|
|
|
|
# Install all packages - this will make running the suite faster
|
|
|
|
echo "--> Installing packages for faster tests"
|
|
|
|
go install -tags="${GOTAGS}" -a ./...
|
|
|
|
fi
|
2017-03-23 19:12:30 -04:00
|
|
|
|
2017-03-23 19:06:09 -04:00
|
|
|
# If we are testing the API, build and install consul
|
|
|
|
if grep -q "/consul/api" <<< "${GOFILES}"; then
|
|
|
|
# Create a temp dir and clean it up on exit
|
|
|
|
TEMPDIR=`mktemp -d -t consul-test.XXX`
|
|
|
|
trap "rm -rf ${TEMPDIR}" EXIT HUP INT QUIT TERM
|
2015-04-11 13:21:56 -07:00
|
|
|
|
2017-03-23 19:06:09 -04:00
|
|
|
# Build the Consul binary for the API tests
|
|
|
|
echo "--> Building consul"
|
|
|
|
go build -tags="${GOTAGS}" -o $TEMPDIR/consul
|
|
|
|
PATH="${TEMPDIR}:${PATH}"
|
|
|
|
fi
|
|
|
|
|
2015-04-11 13:21:56 -07:00
|
|
|
# Run the tests
|
|
|
|
echo "--> Running tests"
|
2017-03-23 21:25:34 -07:00
|
|
|
go test -timeout=360s -tags="${GOTAGS}" ${GOFILES} ${TESTARGS}
|