mirror of https://github.com/golang/go.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 <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>
This commit is contained in:
parent
66c58b946b
commit
54e109ea19
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue