| 1 |
From: =?utf-8?b?T3R0byBLZWvDpGzDpGluZW4=?= <[email protected]> |
| 2 |
Date: Fri, 27 Feb 2026 05:37:12 +0000 |
| 3 |
Subject: Relax benchmark test assertions to fix test failures on slower |
| 4 |
hardware |
| 5 |
|
| 6 |
The benchmark tests were failing because they used hard-coded regex patterns |
| 7 |
that expected specific iteration counts and timing values. These expectations do |
| 8 |
not account for different hardware speeds or build environment load. |
| 9 |
|
| 10 |
Change the regex patterns to use generic digit placeholders (`\d+`) instead of |
| 11 |
specific numeric values. This allows the tests to verify the benchmark output |
| 12 |
formatting works correctly without being sensitive to actual performance |
| 13 |
characteristics of the build machine. |
| 14 |
|
| 15 |
Forwarded: not-needed, upstream has CI and most likely has already fixed this, if their CI wasn't broken for other reasons already |
| 16 |
--- |
| 17 |
benchmark_test.go | 9 ++++++--- |
| 18 |
1 file changed, 6 insertions(+), 3 deletions(-) |
| 19 |
|
| 20 |
diff --git a/benchmark_test.go b/benchmark_test.go |
| 21 |
index 3708e7d..a9d9d04 100644 |
| 22 |
--- a/benchmark_test.go |
| 23 |
+++ b/benchmark_test.go |
| 24 |
@@ -56,7 +56,8 @@ func (s *BenchmarkS) TestBenchmark(c *C) { |
| 25 |
c.Check(helper.calls[6], Equals, "TearDownTest") |
| 26 |
// ... and more. |
| 27 |
|
| 28 |
- expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *100\t *[12][0-9]{5} ns/op\n" |
| 29 |
+ // Relaxed regex to accommodate different machine speeds |
| 30 |
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *\\d+\t *\\d+ ns/op\n" |
| 31 |
c.Assert(output.value, Matches, expected) |
| 32 |
} |
| 33 |
|
| 34 |
@@ -71,7 +72,8 @@ func (s *BenchmarkS) TestBenchmarkBytes(c *C) { |
| 35 |
} |
| 36 |
Run(&helper, &runConf) |
| 37 |
|
| 38 |
- expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *100\t *[12][0-9]{5} ns/op\t *[4-9]\\.[0-9]{2} MB/s\n" |
| 39 |
+ // Relaxed regex to accommodate different machine speeds and throughput |
| 40 |
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *\\d+\t *\\d+ ns/op\t *[0-9]+\\.[0-9]+ MB/s\n" |
| 41 |
c.Assert(output.value, Matches, expected) |
| 42 |
} |
| 43 |
|
| 44 |
@@ -87,6 +89,7 @@ func (s *BenchmarkS) TestBenchmarkMem(c *C) { |
| 45 |
} |
| 46 |
Run(&helper, &runConf) |
| 47 |
|
| 48 |
- expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark3\t *100\t *[12][0-9]{5} ns/op\t *[0-9]+ B/op\t *[1-9] allocs/op\n" |
| 49 |
+ // Relaxed regex to accommodate different machine speeds |
| 50 |
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark3\t *\\d+\t *\\d+ ns/op\t *[0-9]+ B/op\t *[0-9]+ allocs/op\n" |
| 51 |
c.Assert(output.value, Matches, expected) |
| 52 |
} |