]> Cypherpunks.ru repositories - gostls13.git/commitdiff
slices: skip TestGrow allocation test if noopt
authorIan Lance Taylor <iant@golang.org>
Tue, 14 Feb 2023 17:38:18 +0000 (09:38 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 14 Feb 2023 17:50:49 +0000 (17:50 +0000)
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>

src/slices/slices_test.go

index 97030bebbb3b2e80fbd31b9279812700010db4ad..80efb34fc8a718d41a6278f7c3a8824254b566ad 100644 (file)
@@ -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)