]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.24] testing: detect early return from B.Loop
authorAustin Clements <austin@google.com>
Thu, 20 Mar 2025 14:26:54 +0000 (10:26 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 26 Mar 2025 16:41:07 +0000 (09:41 -0700)
commit1d755aa48867de99617155cd1d8564cee1fbfe9e
tree5f8dda825b57be9b7281787264b86915b15e330a
parent9204aca6c2a95277f2e3df4215c515ab38c008c8
[release-branch.go1.24] testing: detect early return from B.Loop

Currently, if a benchmark function returns prior to B.Loop() returning
false, we'll report a bogus result. While there was no way to detect
this with b.N-style benchmarks, one way b.Loop()-style benchmarks are
more robust is that we *can* detect it.

This CL adds a flag to B that tracks if B.Loop() has finished and
checks it after the benchmark completes. If there was an early exit
(not caused by another error), it reports a B.Error.

For #72974.

Change-Id: I731c1350e6df938c0ffa08fcedc11dc147e78854
Reviewed-on: https://go-review.googlesource.com/c/go/+/659656
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/660557
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
src/testing/benchmark.go
src/testing/loop_test.go