From c4d7a6167e6760720f2bee2225be8465c801f332 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Tue, 27 Mar 2018 14:38:41 +0200 Subject: [PATCH] Add `race-check` target to Makefile. Closes #710 (#769) * Add `race-check` and `test-unit-race` target to Makefile. Closes #710 --- Makefile | 27 +++++++++++++++++---------- geth/params/config_test.go | 2 +- t/e2e/whisper/whisper_mailbox_test.go | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index c14ddf4ab..3e4254255 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ XGOIMAGE = statusteam/xgo:$(XGOVERSION) XGOIMAGEIOSSIM = statusteam/xgo-ios-simulator:$(XGOVERSION) networkid ?= StatusChain +gotest_extraflags = DOCKER_IMAGE_NAME ?= statusteam/status-go @@ -122,23 +123,29 @@ docker-test: ##@tests Run tests in a docker container with golang. test: test-unit-coverage ##@tests Run basic, short tests during development test-unit: ##@tests Run unit and integration tests - go test $(UNIT_TEST_PACKAGES) + go test $(UNIT_TEST_PACKAGES) $(gotest_extraflags) test-unit-coverage: ##@tests Run unit and integration tests with coverage - go test -coverpkg= $(UNIT_TEST_PACKAGES) + go test -coverpkg= $(UNIT_TEST_PACKAGES) $(gotest_extraflags) + +test-unit-race: gotest_extraflags=-race +test-unit-race: test-unit ##@tests Run unit and integration tests with -race flag test-e2e: ##@tests Run e2e tests # order: reliability then alphabetical # TODO(tiabc): make a single command out of them adding `-p 1` flag. - go test -timeout 5m ./t/e2e/accounts/... -network=$(networkid) - go test -timeout 5m ./t/e2e/api/... -network=$(networkid) - go test -timeout 5m ./t/e2e/node/... -network=$(networkid) - go test -timeout 50m ./t/e2e/jail/... -network=$(networkid) - go test -timeout 20m ./t/e2e/rpc/... -network=$(networkid) - go test -timeout 20m ./t/e2e/whisper/... -network=$(networkid) - go test -timeout 10m ./t/e2e/transactions/... -network=$(networkid) + go test -timeout 5m ./t/e2e/accounts/... -network=$(networkid) $(gotest_extraflags) + go test -timeout 5m ./t/e2e/api/... -network=$(networkid) $(gotest_extraflags) + go test -timeout 5m ./t/e2e/node/... -network=$(networkid) $(gotest_extraflags) + go test -timeout 50m ./t/e2e/jail/... -network=$(networkid) $(gotest_extraflags) + go test -timeout 20m ./t/e2e/rpc/... -network=$(networkid) $(gotest_extraflags) + go test -timeout 20m ./t/e2e/whisper/... -network=$(networkid) $(gotest_extraflags) + go test -timeout 10m ./t/e2e/transactions/... -network=$(networkid) $(gotest_extraflags) # e2e_test tag is required to include some files from ./lib without _test suffix - go test -timeout 40m -tags e2e_test ./lib -network=$(networkid) + go test -timeout 40m -tags e2e_test ./lib -network=$(networkid) $(gotest_extraflags) + +race-check: gotest_extraflags=-race +race-check: test-e2e ##@tests Run e2e tests with -race flag lint-install: go get -u github.com/alecthomas/gometalinter diff --git a/geth/params/config_test.go b/geth/params/config_test.go index 31edec9ae..b59bcaf65 100644 --- a/geth/params/config_test.go +++ b/geth/params/config_test.go @@ -270,7 +270,7 @@ var loadConfigTestCases = []struct { require.True(t, nodeConfig.ClusterConfig.Enabled, "cluster configuration is expected to be enabled after loading file") enodes := nodeConfig.ClusterConfig.StaticNodes - require.True(t, len(enodes) == 2) + require.Len(t, enodes, 2) }, }, { diff --git a/t/e2e/whisper/whisper_mailbox_test.go b/t/e2e/whisper/whisper_mailbox_test.go index 545acef3b..8cf0d6b8d 100644 --- a/t/e2e/whisper/whisper_mailbox_test.go +++ b/t/e2e/whisper/whisper_mailbox_test.go @@ -79,11 +79,11 @@ func (s *WhisperMailboxSuite) TestRequestMessageFromMailboxAsync() { //Create message filter messageFilterID := s.createPrivateChatMessageFilter(rpcClient, keyID, topic.String()) - //Threre are no messages at filter + //There are no messages at filter messages := s.getMessagesByMessageFilterID(rpcClient, messageFilterID) s.Require().Equal(0, len(messages)) - //Post message matching with filter (key and token) + //Post message matching with filter (key and topic) s.postMessageToPrivate(rpcClient, pubkey.String(), topic.String(), hexutil.Encode([]byte("Hello world!"))) //Get message to make sure that it will come from the mailbox later