gotestyourself / gotestyourself/gotestsum
race detected output inconsistently reported
- Dominant language
- Go
- Stars
- 2.7k
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Description
With the following test and `gotestsum -- -race`, the race detector output is inconsistently output.
```go
package main
import (
"fmt"
"testing"
)
func TestRace(t *testing.T) {
a := 1
go func() {
a = 2
}()
fmt.Println(a)
}
```
Expected (sometimes):
```
✖ . (112ms)
=== Failed
=== FAIL: . TestRace (0.00s)
1
==================
WARNING: DATA RACE
Write at 0x00c000126178 by goroutine 8:
foo.TestRace.func1()
/Users/eric/Downloads/temp/main_test.go:11 +0x2c
Previous read at 0x00c000126178 by goroutine 7:
foo.TestRace()
/Users/eric/Downloads/temp/main_test.go:13 +0xac
testing.tRunner()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1446 +0x188
testing.(*T).Run.func1()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1493 +0x40
Goroutine 8 (running) created at:
foo.TestRace()
/Users/eric/Downloads/temp/main_test.go:10 +0xa0
testing.tRunner()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1446 +0x188
testing.(*T).Run.func1()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1493 +0x40
Goroutine 7 (running) created at:
testing.(*T).Run()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1493 +0x55c
testing.runTests.func1()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1846 +0x90
testing.tRunner()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1446 +0x188
testing.runTests()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1844 +0x6c0
testing.(*M).Run()
/opt/homebrew/Cellar/go/1.19.6/libexec/src/testing/testing.go:1726 +0x870
main.main()
_testmain.go:47 +0x2fc
==================
DONE 1 tests, 1 failure in 0.277s
```
Actual (sometimes):
```
✖ . (115ms)
=== Failed
=== FAIL: . (0.00s)
=== CONT
testing.go:1319: race detected during execution of test
FAIL
FAIL foo 0.115s
DONE 1 tests, 1 failure in 0.281s
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the supplied TestRace example with `gotestsum -- -race` and compare the two reported outputs. Trace how gotestsum handles `go test` race-detector output; done means the detailed race report is reported consistently rather than reduced to the generic failure message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100