2017-03-13 18:05:55 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Run CNI plugin tests.
|
|
|
|
#
|
2017-05-14 23:06:45 -05:00
|
|
|
# This needs sudo, as we'll be creating net interfaces.
|
2017-03-13 18:05:55 +01:00
|
|
|
#
|
|
|
|
set -e
|
|
|
|
|
2017-05-15 16:50:24 +02:00
|
|
|
source ./build.sh
|
2017-04-18 23:39:09 -05:00
|
|
|
|
2017-03-13 18:05:55 +01:00
|
|
|
echo "Running tests"
|
|
|
|
|
2017-08-30 14:19:24 -07:00
|
|
|
# test everything that's not in vendor
|
|
|
|
pushd "$GOPATH/src/$REPO_PATH" >/dev/null
|
2017-08-30 20:22:12 -07:00
|
|
|
ALL_PKGS="$(go list ./... | grep -v vendor | xargs echo)"
|
2017-08-30 14:19:24 -07:00
|
|
|
popd >/dev/null
|
2017-04-18 23:39:09 -05:00
|
|
|
|
2017-08-30 20:22:12 -07:00
|
|
|
GINKGO_FLAGS="-p --randomizeAllSpecs --randomizeSuites --failOnPending --progress"
|
|
|
|
|
2017-04-18 23:39:09 -05:00
|
|
|
# user has not provided PKG override
|
|
|
|
if [ -z "$PKG" ]; then
|
2017-08-30 20:22:12 -07:00
|
|
|
GINKGO_FLAGS="$GINKGO_FLAGS -r ."
|
|
|
|
LINT_TARGETS="$ALL_PKGS"
|
2017-04-18 23:39:09 -05:00
|
|
|
|
|
|
|
# user has provided PKG override
|
|
|
|
else
|
2017-08-30 20:22:12 -07:00
|
|
|
GINKGO_FLAGS="$GINKGO_FLAGS $PKG"
|
|
|
|
LINT_TARGETS="$PKG"
|
2017-04-18 23:39:09 -05:00
|
|
|
fi
|
|
|
|
|
2017-08-30 20:22:12 -07:00
|
|
|
cd "$GOPATH/src/$REPO_PATH"
|
|
|
|
sudo -E bash -c "umask 0; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} ginkgo ${GINKGO_FLAGS}"
|
2017-04-18 23:39:09 -05:00
|
|
|
|
|
|
|
echo "Checking gofmt..."
|
2017-08-30 20:22:12 -07:00
|
|
|
fmtRes=$(go fmt $LINT_TARGETS)
|
2017-04-18 23:39:09 -05:00
|
|
|
if [ -n "${fmtRes}" ]; then
|
2017-08-30 14:19:24 -07:00
|
|
|
echo -e "go fmt checking failed:\n${fmtRes}"
|
2017-04-18 23:39:09 -05:00
|
|
|
exit 255
|
|
|
|
fi
|
2017-03-13 18:05:55 +01:00
|
|
|
|
2017-06-01 18:43:58 +02:00
|
|
|
echo "Checking govet..."
|
2017-08-30 20:22:12 -07:00
|
|
|
vetRes=$(go vet $LINT_TARGETS)
|
2017-06-01 18:43:58 +02:00
|
|
|
if [ -n "${vetRes}" ]; then
|
|
|
|
echo -e "govet checking failed:\n${vetRes}"
|
|
|
|
exit 255
|
|
|
|
fi
|