Skip to content

Commit 0addffe

Browse files
elibentomocy
authored andcommitted
test2json: default to "pass" when the test doesn't report failures
When a test has a TestMain that doesn't run any tests (doesn't invoke m.Run), `go test` passes, but `go test -json` reports a "fail" event though the exit code is still 0. This CL fixes test2json to behave similarly to `go test` in such cases - no output from the test is taken as "pass" by default, not as "fail". Fixes golang#31969 Change-Id: I1829d40fc30dc2879e73974fac416f6a34212ccd Reviewed-on: https://go-review.googlesource.com/c/go/+/192104 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
1 parent ee01676 commit 0addffe

File tree

4 files changed

+3
-2
lines changed

4 files changed

+3
-2
lines changed

src/cmd/internal/test2json/test2json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func (c *converter) flushReport(depth int) {
284284
func (c *converter) Close() error {
285285
c.input.flush()
286286
c.output.flush()
287-
e := &event{Action: "fail"}
287+
e := &event{Action: "pass"}
288288
if c.result != "" {
289289
e.Action = c.result
290290
}

src/cmd/internal/test2json/testdata/benchshort.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
{"Action":"output","Output":"# but to avoid questions of timing, we just use a file with no \\n at all.\n"}
55
{"Action":"output","Output":"BenchmarkFoo \t"}
66
{"Action":"output","Output":"10000 early EOF"}
7-
{"Action":"fail"}
7+
{"Action":"pass"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Action":"pass"}

src/cmd/internal/test2json/testdata/empty.test

Whitespace-only changes.

0 commit comments

Comments
 (0)