Skip to content

Commit 0391768

Browse files
authored
chore: no printing in tests (#151)
1 parent 0410c20 commit 0391768

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

godeltaprof/compat/generics_go21_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ func TestGenericsHashKeyInPprofBuilder(t *testing.T) {
234234
runtime.MemProfileRate = previousRate
235235
}()
236236
for _, sz := range []int{128, 256} {
237-
_ = genericAllocFunc[uint32](sz / 4)
237+
it := genericAllocFunc[uint32](sz / 4)
238+
escape(it)
238239
}
239240
for _, sz := range []int{32, 64} {
240241
it := genericAllocFunc[uint64](sz / 8)
@@ -352,9 +353,13 @@ func WriteHeapProfile(w io.Writer) error {
352353
return dh.Profile(w)
353354
}
354355

356+
var blackhole []any
357+
355358
// make sure a is on the heap
356359
// https://go-review.googlesource.com/c/go/+/649035
357360
// https://go-review.googlesource.com/c/go/+/653856
358361
func escape(a any) {
359-
fmt.Println(a)
362+
blackhole = append(blackhole, a)
363+
blackhole[0] = nil
364+
blackhole = blackhole[:0]
360365
}

godeltaprof/compat/reject_order_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ func TestMutexReject(t *testing.T) {
7070
p1 := bytes.NewBuffer(nil)
7171
err := PrintCountCycleProfile(h.dp, h.opt, p1, scaler, fs)
7272
assert.NoError(t, err)
73-
p1Size := p1.Len()
7473
profile, err := gprofile.Parse(p1)
7574
require.NoError(t, err)
7675
ls := stackCollapseProfile(t, profile)
7776
assert.Len(t, ls, 512)
7877
assert.Len(t, profile.Location, 141)
79-
t.Log("p1 size", p1Size)
8078

8179
p2 := bytes.NewBuffer(nil)
8280
err = PrintCountCycleProfile(h.dp, h.opt, p2, scaler, fs)
@@ -88,7 +86,6 @@ func TestMutexReject(t *testing.T) {
8886
ls = stackCollapseProfile(t, profile)
8987
assert.Len(t, ls, 0)
9088
assert.Len(t, profile.Location, 0)
91-
t.Log("p2 size", p2Size)
9289
})
9390
}
9491
}

godeltaprof/compat/scale_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package compat
22

33
import (
44
"bytes"
5-
"fmt"
65
"io"
76
"math"
87
"runtime"
@@ -61,9 +60,6 @@ func TestScaleMutex(t *testing.T) {
6160
my := findStack(t, res, "github.com/grafana/pyroscope-go/godeltaprof/compat.TestScaleMutex")
6261
require.NotNil(t, my)
6362

64-
fmt.Println(my.value[0], my.value[1])
65-
fmt.Println(expectedCount, expectedTime)
66-
6763
assert.Less(t, math.Abs(float64(my.value[0])-float64(expectedCount)), e*float64(expectedCount))
6864
assert.Less(t, math.Abs(float64(my.value[1])-float64(expectedTime)), e*float64(expectedTime))
6965
}
@@ -109,9 +105,6 @@ func TestScaleBlock(t *testing.T) {
109105
my := findStack(t, res, "github.com/grafana/pyroscope-go/godeltaprof/compat.TestScaleBlock")
110106
require.NotNil(t, my)
111107

112-
fmt.Println(my.value[0], my.value[1])
113-
fmt.Println(expectedCount, expectedTime)
114-
115108
assert.Less(t, math.Abs(float64(my.value[0])-float64(expectedCount)), 0.4*float64(expectedCount))
116109
assert.Less(t, math.Abs(float64(my.value[1])-float64(expectedTime)), 0.4*float64(expectedTime))
117110
}
@@ -166,8 +159,6 @@ func TestScaleHeap(t *testing.T) {
166159
my := findStack(t, res, "github.com/grafana/pyroscope-go/godeltaprof/compat.TestScaleHeap;github.com/grafana/pyroscope-go/godeltaprof/compat.appendBuf")
167160
require.NotNil(t, my)
168161

169-
fmt.Println(my.value)
170-
fmt.Println(expected)
171162
for i := range my.value {
172163
assert.Less(t, math.Abs(float64(my.value[i])-float64(expected[i])), 0.1*float64(expected[i]))
173164
}

godeltaprof/compat/stackcollapse.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package compat
22

33
import (
44
"bytes"
5-
"fmt"
65
"io"
76
"reflect"
87
"regexp"
@@ -46,7 +45,6 @@ func expectNoStackFrames(t *testing.T, buffer *bytes.Buffer, sfPattern string) {
4645
}
4746

4847
func expectStackFrames(t *testing.T, buffer *bytes.Buffer, sfPattern string, values ...int64) {
49-
fmt.Printf("expectStackFrames: %s %+v\n", sfPattern, values)
5048
profile, err := gprofile.ParseData(buffer.Bytes())
5149
require.NoError(t, err)
5250
line := findStack(t, stackCollapseProfile(t, profile), sfPattern)

0 commit comments

Comments
 (0)