From: Ian Lance Taylor Date: Tue, 14 Feb 2023 17:38:18 +0000 (-0800) Subject: slices: skip TestGrow allocation test if noopt X-Git-Tag: go1.21rc1~1562 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=54e109ea197cbf1edd78c9d48a76083db0b0deea;p=gostls13.git slices: skip TestGrow allocation test if noopt Change-Id: Ie444367c6bb16ed78482d1786b546e6daa63444a Reviewed-on: https://go-review.googlesource.com/c/go/+/468196 Reviewed-by: Bryan Mills Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- 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)