-
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: parent B.Cleanup() functions do not run if a sub-benchmark panics #60129
Comments
Thanks for the report. Want to try a fix? |
I took a look, and this probably requires a moderate change to how benchmarks are run. I have a sort-of fix and test, but it isn't completely right: it now swallows panics somewhere (but it does run the cleanup functions!). I think someone who understands more about the internals of the test/benchmark runner is going to need to take a look. I'll submit my not correct fix anyway, in case it is helpful. It turns out that unlike for tests, a panic in a benchmark function is currently not caught at all, so it terminates the process. Tests have code to catch and propagate the panics and report them differently. This is why for my example I included, the test output includes From
From
|
When a sub-benchmark function panics, the parent Cleanup() functions are never run. This attempts to fix this issue. Unfortunately, something is still catching these panics, so the cleanup functions do run, but the panic is not reported. Fixes golang#60129.
Change https://go.dev/cl/494635 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The following benchmark named
BenchmarkSubBenchPanicNeverRunsCleanup
callsb.Cleanup
, then panics in a sub-benchmark. The "higher level" Cleanup functions never run, but the ones in the specific benchmark do. The equivalent code for a Test calling T.Cleanup(), the cleanup functions are run correctly. This is similar to bug as #41355, which had similar problems when panicing in a sub-test. I believe the parent functions should run.What did you expect to see?
The cleanup functions should be called.
What did you see instead?
Only the cleanup function in the same benchmark are called.
The text was updated successfully, but these errors were encountered: