From 6b742b2f84fc4ddea27076aa1e581197d17bd863 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Mon, 6 Feb 2017 11:59:01 -0500 Subject: testing: print extra labels on benchmarks When running benchmarks, print "goos", "goarch", and "pkg" labels. This makes it easier to refer to benchmark logs and understand how they were generated. "pkg" is printed only for benchmarks located in GOPATH. Change-Id: I397cbdd57b9fe8cbabbb354ec7bfba59f5625c42 Reviewed-on: https://go-review.googlesource.com/36356 Run-TryBot: Quentin Smith TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- src/testing/testing.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/testing/testing.go') diff --git a/src/testing/testing.go b/src/testing/testing.go index 5efbc244fe..97c703d8ba 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -766,6 +766,7 @@ func (f matchStringOnly) StartCPUProfile(w io.Writer) error { return e func (f matchStringOnly) StopCPUProfile() {} func (f matchStringOnly) WriteHeapProfile(w io.Writer) error { return errMain } func (f matchStringOnly) WriteProfileTo(string, io.Writer, int) error { return errMain } +func (f matchStringOnly) ImportPath() string { return "" } // Main is an internal function, part of the implementation of the "go test" command. // It was exported because it is cross-package and predates "internal" packages. @@ -795,6 +796,7 @@ type testDeps interface { StopCPUProfile() WriteHeapProfile(io.Writer) error WriteProfileTo(string, io.Writer, int) error + ImportPath() string } // MainStart is meant for use by tests generated by 'go test'. @@ -827,7 +829,7 @@ func (m *M) Run() int { if !testRan && !exampleRan && *matchBenchmarks == "" { fmt.Fprintln(os.Stderr, "testing: warning: no tests to run") } - if !testOk || !exampleOk || !runBenchmarks(m.deps.MatchString, m.benchmarks) || race.Errors() > 0 { + if !testOk || !exampleOk || !runBenchmarks(m.deps.ImportPath(), m.deps.MatchString, m.benchmarks) || race.Errors() > 0 { fmt.Println("FAIL") m.after() return 1 -- cgit v1.3-5-g9baa