From 0f1cb82084435622b2b1c78bd36884cf90f1ab25 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 28 Jul 2016 14:26:08 +0200 Subject: [PATCH] Allow testing only a subset of directories This can be done by calling TESTDIRS="./report ./probe" make tests --- Makefile | 2 +- tools/test | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 170d64a2f4..9b8fd2cc9f 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ $(SCOPE_EXE) $(RUNSVINIT) lint tests shell prog/static.go: $(SCOPE_BACKEND_BUILD -v $(shell pwd)/.pkg:/go/pkg \ --net=host \ -e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL \ - -e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW \ + -e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW -e TESTDIRS \ $(SCOPE_BACKEND_BUILD_IMAGE) SCOPE_VERSION=$(SCOPE_VERSION) GO_BUILD_INSTALL_DEPS=$(GO_BUILD_INSTALL_DEPS) $@ else diff --git a/tools/test b/tools/test index f8d76c56bc..4ee4ca1a4d 100755 --- a/tools/test +++ b/tools/test @@ -47,8 +47,15 @@ fi fail=0 -# NB: Relies on paths being prefixed with './'. -TESTDIRS=( $(git ls-files -- '*_test.go' | grep -vE '^(vendor|prog|experimental)/' | xargs -n1 dirname | sort -u | sed -e 's|^|./|') ) +if [ -z "$TESTDIRS" ]; then + # NB: Relies on paths being prefixed with './'. + TESTDIRS=( $(git ls-files -- '*_test.go' | grep -vE '^(vendor|prog|experimental)/' | xargs -n1 dirname | sort -u | sed -e 's|^|./|') ) +else + # TESTDIRS on the right side is not really an array variable, it + # is just a string with spaces, but it is written like that to + # shut up the shellcheck tool. + TESTDIRS=( $(for d in ${TESTDIRS[*]}; do echo "$d"; done) ) +fi # If running on circle, use the scheduler to work out what tests to run on what shard if [ -n "$CIRCLECI" ] && [ -z "$NO_SCHEDULER" ] && [ -x "$DIR/sched" ]; then