diff --git a/internal/gui/provider_info_avail_test.go b/internal/gui/provider_info_avail_test.go index 38a3e577d..89895700b 100644 --- a/internal/gui/provider_info_avail_test.go +++ b/internal/gui/provider_info_avail_test.go @@ -54,6 +54,9 @@ func TestProviderInfoReadsTheListOnce(t *testing.T) { t.Fatalf("exposed %d of %d, first %+v", got.Exposed, len(p.Exposed()), got.Models[0]) } + if raceOn { + t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates") + } bytesPer := func(f func()) uint64 { f() var a, b runtime.MemStats diff --git a/internal/gui/providerswrite_test.go b/internal/gui/providerswrite_test.go index 4e556f2c5..a102ba3a0 100644 --- a/internal/gui/providerswrite_test.go +++ b/internal/gui/providerswrite_test.go @@ -51,6 +51,9 @@ func TestProvidersWrittenAsEncoded(t *testing.T) { // buffer to its size: 27 MB of what forty polls allocated. Each provider // is encoded alone now. func TestProvidersWriteGrowsNoBufferItsSize(t *testing.T) { + if raceOn { + t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates") + } s := bigProviders() w := &sinkWriter{} writeProvidersJSON(w, s) // json's encoders, warmed diff --git a/internal/gui/race_off_test.go b/internal/gui/race_off_test.go new file mode 100644 index 000000000..1d46792ca --- /dev/null +++ b/internal/gui/race_off_test.go @@ -0,0 +1,5 @@ +//go:build !race + +package gui + +const raceOn = false diff --git a/internal/gui/race_on_test.go b/internal/gui/race_on_test.go new file mode 100644 index 000000000..7749b542f --- /dev/null +++ b/internal/gui/race_on_test.go @@ -0,0 +1,8 @@ +//go:build race + +package gui + +// raceOn says the tests run under -race, where sync.Pool lets a quarter of +// what is put in it go (json's encoders, regexp's matchers), so a test of +// how much a path allocates skips its bound. +const raceOn = true diff --git a/internal/gui/statewrite_test.go b/internal/gui/statewrite_test.go index b1fdc1c12..374d39fa4 100644 --- a/internal/gui/statewrite_test.go +++ b/internal/gui/statewrite_test.go @@ -88,6 +88,9 @@ func TestStateWrittenAsEncoded(t *testing.T) { // and for keepState's sum, growing a buffer to its size each time: 68 MB // of what twenty polls allocated. Each agent is encoded once now, alone. func TestStateWriteGrowsNoBufferItsSize(t *testing.T) { + if raceOn { + t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates") + } s := bigState() w := &sinkWriter{} writeStateJSON(w, s) // json's encoders, warmed diff --git a/internal/gui/stats_answer_test.go b/internal/gui/stats_answer_test.go index 96b532755..a042d8fec 100644 --- a/internal/gui/stats_answer_test.go +++ b/internal/gui/stats_answer_test.go @@ -87,6 +87,9 @@ func TestSameAnswerNotHeldWhole(t *testing.T) { // writeJSONRows holds no answer-sized buffer: the list goes out a row at a // time, and the whole answer was 25 MB of a warm start's live heap (#2278). func TestJSONRowsNotHeldWhole(t *testing.T) { + if raceOn { + t.Skip("-race: sync.Pool drops what it holds, so allocations are not what a build allocates") + } big := string(bytes.Repeat([]byte("x"), 64<<10)) rows := make([]rowsBufRow, 64) for i := range rows {