aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-02-14 09:38:18 -0800
committerGopher Robot <gobot@golang.org>2023-02-14 17:50:49 +0000
commit54e109ea197cbf1edd78c9d48a76083db0b0deea (patch)
treebcfa13c86f84e713bc822e4d9c01d758dda125b2 /src
parent66c58b946beaa38de35241c3f64ec358f5ad03f1 (diff)
downloadgo-54e109ea197cbf1edd78c9d48a76083db0b0deea.tar.xz
slices: skip TestGrow allocation test if noopt
Change-Id: Ie444367c6bb16ed78482d1786b546e6daa63444a Reviewed-on: https://go-review.googlesource.com/c/go/+/468196 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/slices/slices_test.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/slices/slices_test.go b/src/slices/slices_test.go
index 97030bebbb..80efb34fc8 100644
--- a/src/slices/slices_test.go
+++ b/src/slices/slices_test.go
@@ -6,6 +6,7 @@ package slices
import (
"internal/race"
+ "internal/testenv"
"math"
"strings"
"testing"
@@ -455,7 +456,7 @@ func TestGrow(t *testing.T) {
}
if n := testing.AllocsPerRun(100, func() { Grow(s2, cap(s2)-len(s2)+1) }); n != 1 {
errorf := t.Errorf
- if race.Enabled {
+ if race.Enabled || testenv.OptimizationOff() {
errorf = t.Logf // this allocates multiple times in race detector mode
}
errorf("Grow should allocate once when given insufficient capacity; allocated %v times", n)