Skip to content

Commit

Permalink
slog/internal/buffer: don't run alloc test with race detector
Browse files Browse the repository at this point in the history
Fixes golang/go#54978.

Change-Id: I42d1f952e7f9f8469f640763fc3363d087583918
Reviewed-on: https://go-review.googlesource.com/c/exp/+/431056
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
Run-TryBot: Jonathan Amsterdam <[email protected]>
  • Loading branch information
jba committed Sep 16, 2022
1 parent 840b380 commit b168a2c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 0 additions & 11 deletions slog/internal/buffer/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,3 @@ func Test(t *testing.T) {
t.Errorf("got %q, want %q", got, want)
}
}

func TestAlloc(t *testing.T) {
got := int(testing.AllocsPerRun(5, func() {
b := New()
defer b.Free()
b.WriteString("not 1K worth of bytes")
}))
if got != 0 {
t.Errorf("got %d allocs, want 0", got)
}
}
20 changes: 20 additions & 0 deletions slog/internal/buffer/norace_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !race

package buffer

import "testing"

func TestAlloc(t *testing.T) {
got := int(testing.AllocsPerRun(5, func() {
b := New()
defer b.Free()
b.WriteString("not 1K worth of bytes")
}))
if got != 0 {
t.Errorf("got %d allocs, want 0", got)
}
}

0 comments on commit b168a2c

Please sign in to comment.