Skip to content

testing: (*testing.Benchmark).Log always logs #10713

@jeffallen

Description

@jeffallen

With this benchmark:

package main
import "testing"
func BenchmarkLog(b *testing.B) {
b.Log("why?")
}

I get this output:

$ go test -bench .
testing: warning: no tests to run
PASS
BenchmarkLog 2000000000 0.00 ns/op
--- BENCH: BenchmarkLog
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?
issue_test.go:6: why?

The docs say, "The text will be printed only if the test fails or the -test.v flag is set."

Why is b.Log logging anyway?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions