enable -race on go test (#7305)
Introduce 'norace' build tag that is used to filter out test files containing test cases or test suites that, if run with the -race flag on would cause race conditions. Supersede #7300.
This commit is contained in:
parent
a8990eab71
commit
7ada179aef
89
.github/workflows/test.yml
vendored
89
.github/workflows/test.yml
vendored
@ -31,6 +31,7 @@ jobs:
|
||||
- name: Run cosmovisor tests
|
||||
run: cd cosmovisor; make
|
||||
if: "env.GIT_DIFF != ''"
|
||||
|
||||
split-test-files:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@ -76,7 +77,7 @@ jobs:
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: test & coverage report creation
|
||||
run: |
|
||||
cat xaa.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock'
|
||||
cat xaa.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: filter out DONTCOVER
|
||||
run: |
|
||||
@ -113,7 +114,7 @@ jobs:
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: test & coverage report creation
|
||||
run: |
|
||||
cat xab.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock'
|
||||
cat xab.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: filter out DONTCOVER
|
||||
run: |
|
||||
@ -150,7 +151,7 @@ jobs:
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: test & coverage report creation
|
||||
run: |
|
||||
cat xac.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock'
|
||||
cat xac.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: filter out DONTCOVER
|
||||
run: |
|
||||
@ -187,7 +188,7 @@ jobs:
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: test & coverage report creation
|
||||
run: |
|
||||
cat xad.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock'
|
||||
cat xad.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: filter out DONTCOVER
|
||||
run: |
|
||||
@ -205,6 +206,86 @@ jobs:
|
||||
file: ./coverage.txt
|
||||
if: "env.GIT_DIFF != ''"
|
||||
|
||||
test-race-1:
|
||||
runs-on: ubuntu-latest
|
||||
needs: split-test-files
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
.go
|
||||
.mod
|
||||
.sum
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: "${{ github.sha }}-aa"
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: Run tests with race detector
|
||||
run: cat xaa.txt | xargs go test -mod=readonly -timeout 15m -race -tags='cgo ledger test_ledger_mock'
|
||||
|
||||
test-race-2:
|
||||
runs-on: ubuntu-latest
|
||||
needs: split-test-files
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
.go
|
||||
.mod
|
||||
.sum
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: "${{ github.sha }}-ab"
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: Run tests with race detector
|
||||
run: cat xab.txt | xargs go test -mod=readonly -timeout 15m -race -tags='cgo ledger test_ledger_mock'
|
||||
|
||||
test-race-3:
|
||||
runs-on: ubuntu-latest
|
||||
needs: split-test-files
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
.go
|
||||
.mod
|
||||
.sum
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: "${{ github.sha }}-ac"
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: Run tests with race detector
|
||||
run: cat xac.txt | xargs go test -mod=readonly -timeout 15m -race -tags='cgo ledger test_ledger_mock'
|
||||
|
||||
test-race-4:
|
||||
runs-on: ubuntu-latest
|
||||
needs: split-test-files
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: technote-space/get-diff-action@v3
|
||||
id: git_diff
|
||||
with:
|
||||
SUFFIX_FILTER: |
|
||||
.go
|
||||
.mod
|
||||
.sum
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: "${{ github.sha }}-ad"
|
||||
if: "env.GIT_DIFF != ''"
|
||||
- name: Run tests with race detector
|
||||
run: cat xad.txt | xargs go test -mod=readonly -timeout 15m -race -tags='cgo ledger test_ledger_mock'
|
||||
|
||||
liveness-test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
8
Makefile
8
Makefile
@ -211,10 +211,10 @@ TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-
|
||||
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
|
||||
# append the new rule to the TEST_TARGETS list.
|
||||
|
||||
test-unit: ARGS=-tags='cgo ledger test_ledger_mock'
|
||||
test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino'
|
||||
test-ledger: ARGS=-tags='cgo ledger'
|
||||
test-ledger-mock: ARGS=-tags='ledger test_ledger_mock'
|
||||
test-unit: ARGS=-tags='cgo ledger test_ledger_mock norace'
|
||||
test-unit-amino: ARGS=-tags='ledger test_ledger_mock test_amino norace'
|
||||
test-ledger: ARGS=-tags='cgo ledger norace'
|
||||
test-ledger-mock: ARGS=-tags='ledger test_ledger_mock norace'
|
||||
test-race: ARGS=-race -tags='cgo ledger test_ledger_mock'
|
||||
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package client_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package grpc_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package network_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package rest_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package rest_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package rest_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package rest_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package rest_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// +build norace
|
||||
|
||||
package rest_test
|
||||
|
||||
import (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user