2015-04-11 20:21:56 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-11-03 00:27:49 +00:00
|
|
|
set -e
|
2016-02-13 00:50:37 +00:00
|
|
|
|
2017-03-23 23:14:38 +00: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 23:12:30 +00:00
|
|
|
|
2017-03-23 23:06:09 +00: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 20:21:56 +00:00
|
|
|
|
2017-03-23 23:06:09 +00: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 20:21:56 +00:00
|
|
|
# Run the tests
|
|
|
|
echo "--> Running tests"
|
2017-03-24 04:25:34 +00:00
|
|
|
go test -timeout=360s -tags="${GOTAGS}" ${GOFILES} ${TESTARGS}
|