mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 05:37:32 +00:00
all: use testingutil.MinAllocsPerRun
There are a few remaining uses of testing.AllocsPerRun: Two in which we only log the number of allocations, and one in which dynamically calculate the allocations target based on a different AllocsPerRun run. This also allows us to tighten the "no allocs" test in wgengine/filter. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:

committed by
Josh Bleecher Snyder

parent
1df865a580
commit
94fb42d4b2
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"tailscale.com/tstest"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
@@ -39,11 +40,11 @@ func TestParse(t *testing.T) {
|
||||
if diff := cmp.Diff(gotParsed, test.parsed); diff != "" {
|
||||
t.Errorf("parse(%q) diff (-got+want):\n%s", test.version, diff)
|
||||
}
|
||||
n := int(testing.AllocsPerRun(1000, func() {
|
||||
err := tstest.MinAllocsPerRun(t, 0, func() {
|
||||
gotParsed, got = parse(test.version)
|
||||
}))
|
||||
if n != 0 {
|
||||
t.Errorf("parse(%q) allocs = %d; want 0", test.version, n)
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("parse(%q): %v", test.version, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user