| 1 |
[short] skip 'builds test binary' |
| 2 |
|
| 3 |
go list -test -f '{{.ImportPath}} {{.DefaultGODEBUG}}' |
| 4 |
stdout 'example.com/foo\.test.*panicnil=1.*' |
| 5 |
|
| 6 |
go test -c |
| 7 |
go version -m ./foo.test$GOEXE |
| 8 |
stdout 'build\tDefaultGODEBUG=.*panicnil=1.*' |
| 9 |
|
| 10 |
-- go.mod -- |
| 11 |
module example.com/foo |
| 12 |
|
| 13 |
go 1.23 |
| 14 |
-- main_test.go -- |
| 15 |
//go:debug panicnil=1 |
| 16 |
package main_test |
| 17 |
|
| 18 |
import ( |
| 19 |
"runtime/debug" |
| 20 |
"testing" |
| 21 |
) |
| 22 |
|
| 23 |
func TestFoo(t *testing.T) { |
| 24 |
defer func() { |
| 25 |
t.Fatal(recover()) |
| 26 |
}() |
| 27 |
|
| 28 |
t.Log(debug.ReadBuildInfo()) |
| 29 |
panic(nil) |
| 30 |
} |