-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: reject calls to Run within Cleanup callbacks #48515
Comments
Don't think too hard about this. Make t.Run panic during t.Cleanup callbacks. |
Change https://golang.org/cl/352349 mentions this issue: |
Change https://go.dev/cl/451215 mentions this issue: |
… cleanup Also tweak the failure message added in CL 352349. Updates #18741. Updates #48515. Change-Id: I46ed84c6f498d7a68414cc3dab3c1cd55da69aa9 Reviewed-on: https://go-review.googlesource.com/c/go/+/451215 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Changkun Ou <mail@changkun.de> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
FWIW, this broke a BDD-style structured testing library I maintain. It caught me off-guard because it wasn't mentioned in the go 1.20 release notes. As soon as I updated to In the library, for the moment I've had to add: //go:build go1.20
package onpar
func init() {
panic("onpar v2 is broken in go v1.20.")
} |
@nelsam Thanks. I sent https://go.dev/cl/475215 to mention this in the release notes. |
Change https://go.dev/cl/475215 mentions this issue: |
Thanks! The docs weren't very clear if it was supported, so I tried it and it worked. And it felt a lot cleaner than our old I still don't know how I'm going to fix it, but I'm at least glad that the breaking change is in the release notes now. |
For golang/go#48515 Change-Id: I1c616144a58e92fe4022d0e86f4208d68dcce816 Reviewed-on: https://go-review.googlesource.com/c/website/+/475215 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
What version of Go are you using (
go version
)?go1.17.1
Does this issue reproduce with the latest release?
Yes.
What did you do?
https://play.golang.org/p/l8yW_gkioCx:
What did you expect to see?
Per https://pkg.go.dev/testing#T.Cleanup:
So a
Cleanup
callback should not be started while there are subtests of its parent test still outstanding. Thus, either:t.Run
within aCleanup
callback panics the test, orCleanup
callback is executed after all of the subtests spawned by the second-addedCleanup
callback have completed.That would give an output like:
What did you see instead?
The first
Cleanup
callback is executed before the parallel subtests spawned by the secondCleanup
callback are run.CC @ianlancetaylor @changkun @rogpeppe @jayconrod
The text was updated successfully, but these errors were encountered: