From c1f2542c8bef27872a95efd7904afeeee36fe976 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 12 Dec 2024 21:17:04 -0500 Subject: testing: improve B.Loop test This moves the B.Loop test from package testing_test to package testing, where it can check on more of the internals of the benchmark state. Updates #61515. Change-Id: Ia32d7104526125c5e8a1e35dab7660008afcbf80 Reviewed-on: https://go-review.googlesource.com/c/go/+/635897 Auto-Submit: Austin Clements LUCI-TryBot-Result: Go LUCI Reviewed-by: Junyang Shao --- src/testing/benchmark_test.go | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'src/testing/benchmark_test.go') diff --git a/src/testing/benchmark_test.go b/src/testing/benchmark_test.go index 239e730021..a195e4c576 100644 --- a/src/testing/benchmark_test.go +++ b/src/testing/benchmark_test.go @@ -127,28 +127,6 @@ func TestRunParallelSkipNow(t *testing.T) { }) } -func TestBLoopHasResults(t *testing.T) { - // Verify that b.N and the b.Loop() iteration count match. - var nIterated int - bRet := testing.Benchmark(func(b *testing.B) { - i := 0 - for b.Loop() { - i++ - } - nIterated = i - }) - if nIterated == 0 { - t.Fatalf("Iteration count zero") - } - if bRet.N != nIterated { - t.Fatalf("Benchmark result N incorrect, got %d want %d", bRet.N, nIterated) - } - // We only need to check duration to make sure benchmark result is written. - if bRet.T == 0 { - t.Fatalf("Benchmark result duration unset") - } -} - func ExampleB_RunParallel() { // Parallel benchmark for text/template.Template.Execute on a single object. testing.Benchmark(func(b *testing.B) { -- cgit v1.3