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