aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/test2json
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2018-01-05 16:06:47 -0500
committerRuss Cox <rsc@golang.org>2018-01-05 22:27:17 +0000
commit65fa53183b3978085e20e3f5794e88ae8c2671c1 (patch)
tree97fe206782e91dce9d7f8545baf7a6fbf1865fa4 /src/cmd/test2json
parentacc1ec9b9d2724e58babf533068ac2d23225f8cb (diff)
downloadgo-65fa53183b3978085e20e3f5794e88ae8c2671c1.tar.gz
go-65fa53183b3978085e20e3f5794e88ae8c2671c1.zip
cmd/test2json: fix processing of --- BENCH: output
If a benchmark calls b.Log without failing (without b.Error/b.Fatal/b.FailNow) then that turns into output very much like a test passing, except it says BENCH instead of PASS. Benchmarks failing say FAIL just like tests failing. Fixes #23346. Change-Id: Ib188e695952da78057ab4a13f90d49937aa3c232 Reviewed-on: https://go-review.googlesource.com/86396 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/test2json')
-rw-r--r--src/cmd/test2json/main.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cmd/test2json/main.go b/src/cmd/test2json/main.go
index 7bdc867bbe..654c00a6df 100644
--- a/src/cmd/test2json/main.go
+++ b/src/cmd/test2json/main.go
@@ -45,7 +45,8 @@
// pause - the test has been paused
// cont - the test has continued running
// pass - the test passed
-// fail - the test failed
+// bench - the benchmark printed log output but did not fail
+// fail - the test or benchmark failed
// output - the test printed output
//
// The Package field, if present, specifies the package being tested.
@@ -53,7 +54,7 @@
// different tests are interlaced; the Package field allows readers to
// separate them.
//
-// The Test field, if present, specifies the test or example, or benchmark
+// The Test field, if present, specifies the test, example, or benchmark
// function that caused the event. Events for the overall package test
// do not set Test.
//
@@ -67,6 +68,14 @@
// the concatenation of the Output fields of all output events is the exact
// output of the test execution.
//
+// When a benchmark runs, it typically produces a single line of output
+// giving timing results. That line is reported in an event with Action == "output"
+// and no Test field. If a benchmark logs output or reports a failure
+// (for example, by using b.Log or b.Error), that extra output is reported
+// as a sequence of events with Test set to the benchmark name, terminated
+// by a final event with Action == "bench" or "fail".
+// Benchmarks have no events with Action == "run", "pause", or "cont".
+//
package main
import (