From 6cf3db62445cdc1e7081d721ee483b31ff4fbbae Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Thu, 3 Jan 2019 15:27:41 -0500 Subject: [PATCH] Support make test WHAT=..... Signed-off-by: Andy Goldstein --- Makefile | 8 +++----- hack/test.sh | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index d4356cba1..296ba5b81 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/hack/test.sh b/hack/test.sh index 1f85de673..deaf5ce3c 100755 --- a/hack/test.sh +++ b/hack/test.sh @@ -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!"