Skip to content

Commit

Permalink
Activate race-detection for those modules that are passing it
Browse files Browse the repository at this point in the history
At present, the unit tests run as part of every CI build, but they do not run with with -race parameter which may be used to detect [data races](https://golang.org/doc/articles/race_detector).

Since data races may lead to instability and crashes, it's beneficial to ensure that we prevent data races from being introduced where possible. This runs unit tests with an explicit list of modules (rather than the recursive catch-all) and turns on `-race` for those that pass the build today, hoping others will join the list in the future.

To determine which modules "pass" with `-race` enabled, I've run `go test -race` in a loop and moved any directories that had a test failing because of a race condition move to the Makefile line (part of the unittest goal) without race detection.
  • Loading branch information
huitseeker committed Jul 5, 2021
1 parent 2641774 commit 845a00b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ install-tools: crypto/relic/build check-go-version

.PHONY: unittest
unittest:
# test some packages with Relic library and data race detection enabled
GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) -covermode=atomic $(if $(JSON_OUTPUT),-json,) -race --tags relic ./access/... ./consensus/... ./model/... ./state/... ./storage/... ./utils/...
# test all packages with Relic library enabled
GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) -covermode=atomic $(if $(JSON_OUTPUT),-json,) --tags relic ./...
GO111MODULE=on go test -coverprofile=$(COVER_PROFILE) -covermode=atomic $(if $(JSON_OUTPUT),-json,) --tags relic ./cmd... ./engine/... ./fvm/... ./ledger/... ./module/... ./network/...
$(MAKE) -C crypto test
$(MAKE) -C integration test

Expand Down

0 comments on commit 845a00b

Please sign in to comment.