aboutsummaryrefslogtreecommitdiff
path: root/src/testing/panic_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/panic_test.go')
-rw-r--r--src/testing/panic_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/testing/panic_test.go b/src/testing/panic_test.go
index fafcff790e..4648057b77 100644
--- a/src/testing/panic_test.go
+++ b/src/testing/panic_test.go
@@ -224,6 +224,11 @@ func TestMorePanic(t *testing.T) {
want: `panic: die
panic: test executed panic(nil) or runtime.Goexit`,
},
+ {
+ desc: "Issue 48515: call t.Run in t.Cleanup should trigger panic",
+ flags: []string{"-test.run=TestCallRunInCleanupHelper"},
+ want: `panic: testing: t.Run is called during t.Cleanup`,
+ },
}
for _, tc := range testCases {
@@ -239,6 +244,18 @@ func TestMorePanic(t *testing.T) {
}
}
+func TestCallRunInCleanupHelper(t *testing.T) {
+ if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
+ return
+ }
+
+ t.Cleanup(func() {
+ t.Run("in-cleanup", func(t *testing.T) {
+ t.Log("must not be executed")
+ })
+ })
+}
+
func TestGoexitInCleanupAfterPanicHelper(t *testing.T) {
if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
return