Skip to content

Commit

Permalink
[FAB-10880] Disable test cache by default
Browse files Browse the repository at this point in the history
This change updates the Makefile to disable the Go test cache
by default. The unit and integration tests contain logic to
determine when to run tests.

The all target is also fixed to not run linters twice.

Change-Id: I9b417f3d7bb81572188e5c120e8dd9363d3783d6
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Jun 26, 2018
1 parent 2a53231 commit c3f53d8
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ FABRIC_PREV_VERSION_MINOR := 1.0

# Build flags (overridable)
GO_LDFLAGS ?=
GO_TESTFLAGS ?=
GO_TESTFLAGS ?= -count=1
FABRIC_SDK_EXPERIMENTAL ?= true
FABRIC_SDK_EXTRA_GO_TAGS ?=
FABRIC_SDK_POPULATE_VENDOR ?= true
Expand Down Expand Up @@ -176,7 +176,7 @@ export DOCKER_CMD
export DOCKER_COMPOSE_CMD

.PHONY: all
all: checks lint-all unit-test integration-test
all: depend license unit-test integration-test

.PHONY: depend
depend:
Expand Down Expand Up @@ -216,7 +216,7 @@ build-softhsm2-image:
unit-test: license depend populate lint-integration-tests
@TEST_CHANGED_ONLY=true TEST_WITH_LINTER=true FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit.sh
ifeq ($(FABRIC_SDK_DEPRECATED_UNITTEST),true)
@GO_TAGS="$(GO_TAGS) deprecated" TEST_CHANGED_ONLY=true GO_TESTFLAGS="$(GO_TESTFLAGS) -count=1" FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit.sh
@GO_TAGS="$(GO_TAGS) deprecated" TEST_CHANGED_ONLY=true FABRIC_SDKGO_CODELEVEL=$(FABRIC_CODELEVEL_UNITTEST_TAG) FABRIC_SDKGO_CODELEVEL_VER=$(FABRIC_CODELEVEL_UNITTEST_VER) $(TEST_SCRIPTS_PATH)/unit.sh
endif

.PHONY: unit-tests
Expand Down
1 change: 1 addition & 0 deletions test/scripts/check_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare -a PKG_SRC=(
"./pkg"
"./test"
)
declare PKG_EXCLUDE=""
findPackages

# Reduce Linter checks to changed packages.
Expand Down
1 change: 1 addition & 0 deletions test/scripts/check_lint_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ source ${SCRIPT_DIR}/lib/linter.sh
declare -a PKG_SRC=(
"./test"
)
declare PKG_EXCLUDE=""
findPackages

# Reduce Linter checks to changed packages.
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/expiredorderer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ echo "Running integration tests for expired orderer certificates ..."

GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG"
GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_SDKGO_CODELEVEL_VER}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config"
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE}
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE}
2 changes: 1 addition & 1 deletion test/scripts/expiredpeer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ echo "Running integration tests for expired peer certificates ..."

GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG"
GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_SDKGO_CODELEVEL_VER}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config"
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE}
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE}
2 changes: 1 addition & 1 deletion test/scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ echo "Running integration tests ..."

GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG"
GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_FIXTURE_VERSION}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config"
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE} testLocal=${TEST_LOCAL}
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE} testLocal=${TEST_LOCAL}
2 changes: 1 addition & 1 deletion test/scripts/lib/find_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function findPackages {
declare -a FOUND_PKGS=($(${GO_CMD} list ${i}/... 2> /dev/null | tr '\n' ' '))
for pkg in "${FOUND_PKGS[@]}"
do
if [[ ! "${pkg}" =~ $PKG_EXCLUDE ]]; then
if [ -z "${PKG_EXCLUDE}" ] || [[ ! "${pkg}" =~ $PKG_EXCLUDE ]]; then
PKGS+=("${pkg}")
fi
done
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/revoked.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ echo "Running integration tests for revoked certificates ..."

GO_TAGS="$GO_TAGS $FABRIC_SDKGO_CODELEVEL_TAG"
GO_LDFLAGS="$GO_LDFLAGS -X github.com/hyperledger/fabric-sdk-go/test/metadata.ChannelConfigPath=test/fixtures/fabric/${FABRIC_SDKGO_CODELEVEL_VER}/channel -X github.com/hyperledger/fabric-sdk-go/test/metadata.CryptoConfigPath=test/fixtures/fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config"
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m -count=1 configFile=${CONFIG_FILE}
$GO_CMD test $RACEFLAG -tags "$GO_TAGS" $GO_TESTFLAGS -ldflags="$GO_LDFLAGS" ${PKGS[@]} -p 1 -timeout=40m configFile=${CONFIG_FILE}
1 change: 0 additions & 1 deletion test/scripts/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ declare -a PKG_SRC=(
"./pkg"
)
declare PKG_EXCLUDE="(${REPO}/pkg/core/cryptosuite/bccsp/multisuite|${REPO}/pkg/core/cryptosuite/bccsp/pkcs11)"

findPackages

# Reduce unit tests to changed packages.
Expand Down

0 comments on commit c3f53d8

Please sign in to comment.