Support make test WHAT=.....

Signed-off-by: Andy Goldstein <goldsteina@vmware.com>
pull/1140/head
Andy Goldstein 2019-01-03 15:27:41 -05:00
parent fd8bf14bb6
commit 6cf3db6244
No known key found for this signature in database
GPG Key ID: 40F5986D66395469
2 changed files with 18 additions and 8 deletions

View File

@ -37,8 +37,6 @@ TAG_LATEST ?= false
### These variables should not need tweaking.
###
SRC_DIRS := cmd pkg # directories which hold app source (not vendored)
CLI_PLATFORMS := linux-amd64 linux-arm linux-arm64 darwin-amd64 windows-amd64
CONTAINER_PLATFORMS := linux-amd64 linux-arm linux-arm64
@ -63,7 +61,7 @@ IMAGE = $(REGISTRY)/$(BIN)
# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-container' rule.
# If you want to build AND push all containers, see the 'all-push' rule.
all:
all:
@$(MAKE) build
@$(MAKE) build BIN=ark-restic-restore-helper
@ -181,12 +179,12 @@ push-name:
SKIP_TESTS ?=
test: build-dirs
ifneq ($(SKIP_TESTS), 1)
@$(MAKE) shell CMD="-c 'hack/test.sh $(SRC_DIRS)'"
@$(MAKE) shell CMD="-c 'hack/test.sh $(WHAT)'"
endif
test-local: build-dirs
ifneq ($(SKIP_TESTS), 1)
hack/test.sh $(SRC_DIRS)
hack/test.sh $(WHAT)
endif
verify:

View File

@ -20,8 +20,20 @@ set -o pipefail
export CGO_ENABLED=0
TARGETS=$(for d in "$@"; do echo ./$d/...; done)
TARGETS=(
./cmd/...
./pkg/...
)
echo "Running tests:"
go test -installsuffix "static" -timeout 60s ${TARGETS}
if [[ ${#@} -ne 0 ]]; then
TARGETS=("$@")
fi
echo "Running tests:" "${TARGETS[@]}"
if [[ -n "${GOFLAGS:-}" ]]; then
echo "GOFLAGS: ${GOFLAGS}"
fi
go test -installsuffix "static" -timeout 60s "${TARGETS[@]}"
echo "Success!"