Compare commits

...

1 Commits

Author SHA1 Message Date
Ayke van Laethem 730da698a3 testing: run cleanups after exiting a benchmark run
This is important, otherwise temporary directories don't get removed.

Issue found while working on Go 1.20 support.
2025-10-03 10:35:24 +02:00
+2
View File
@@ -159,6 +159,7 @@ func (b *B) ReportAllocs() {
// runN runs a single benchmark for the specified number of iterations.
func (b *B) runN(n int) {
b.runCleanup() // start fresh in the next iteration
b.N = n
runtime.GC()
b.ResetTimer()
@@ -457,6 +458,7 @@ func (b *B) Run(name string, f func(b *B)) bool {
// Only process sub-benchmarks, if any.
sub.hasSub = true
}
defer sub.runCleanup() // make sure all cleanups are run, even when panicking
if sub.run1() {
sub.run()
}