2015-06-01 13:25:51 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-08-19 23:32:41 +00:00
|
|
|
set -e
|
2015-06-01 13:25:51 +00:00
|
|
|
|
2017-01-25 18:54:08 +00:00
|
|
|
GOTEST_TAGS="nomad_test"
|
|
|
|
if [[ $(uname) == "Linux" ]]; then
|
|
|
|
if pkg-config --exists lxc; then
|
|
|
|
GOTEST_TAGS="$GOTEST_TAGS lxc"
|
|
|
|
fi
|
|
|
|
fi
|
2016-10-26 22:53:38 +00:00
|
|
|
|
2015-06-01 13:25:51 +00:00
|
|
|
# Create a temp dir and clean it up on exit
|
|
|
|
TEMPDIR=`mktemp -d -t nomad-test.XXX`
|
|
|
|
trap "rm -rf $TEMPDIR" EXIT HUP INT QUIT TERM
|
|
|
|
|
|
|
|
# Build the Nomad binary for the API tests
|
|
|
|
echo "--> Building nomad"
|
2017-01-27 21:22:58 +00:00
|
|
|
echo go build -i -tags \"$GOTEST_TAGS\" -o $TEMPDIR/nomad
|
2017-01-25 18:54:08 +00:00
|
|
|
go build -i -tags "$GOTEST_TAGS" -o $TEMPDIR/nomad || exit 1
|
2015-06-01 13:25:51 +00:00
|
|
|
|
|
|
|
# Run the tests
|
|
|
|
echo "--> Running tests"
|
2016-07-11 19:49:26 +00:00
|
|
|
GOBIN="`which go`"
|
2016-10-18 23:58:25 +00:00
|
|
|
sudo -E PATH=$TEMPDIR:$PATH -E GOPATH=$GOPATH -E NOMAD_TEST_RKT=1 \
|
2017-07-21 03:28:31 +00:00
|
|
|
$GOBIN test -tags "$GOTEST_TAGS" ${GOTEST_FLAGS:--cover -timeout=900s} $($GOBIN list ./... | grep -v /vendor/)
|
2016-08-16 19:32:29 +00:00
|
|
|
|