]> Cypherpunks repositories - gostls13.git/commitdiff
test2json: default to "pass" when the test doesn't report failures
authorEli Bendersky <eliben@google.com>
Wed, 28 Aug 2019 19:34:48 +0000 (12:34 -0700)
committerIan Lance Taylor <iant@golang.org>
Sat, 31 Aug 2019 01:06:32 +0000 (01:06 +0000)
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 #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>
src/cmd/internal/test2json/test2json.go
src/cmd/internal/test2json/testdata/benchshort.json
src/cmd/internal/test2json/testdata/empty.json [new file with mode: 0644]
src/cmd/internal/test2json/testdata/empty.test [new file with mode: 0644]

index f8052136be625025bd47f8e2d771e837c44794e6..aa63c8b9a629f0d28ba3abb5dca5dca895f4f8b7 100644 (file)
@@ -284,7 +284,7 @@ func (c *converter) flushReport(depth int) {
 func (c *converter) Close() error {
        c.input.flush()
        c.output.flush()
-       e := &event{Action: "fail"}
+       e := &event{Action: "pass"}
        if c.result != "" {
                e.Action = c.result
        }
index 8c61d95d8da0235d23a2a2fd4576baf087006e96..28e287c848a678ba2c9f748a0f054b090ed1d78e 100644 (file)
@@ -4,4 +4,4 @@
 {"Action":"output","Output":"# but to avoid questions of timing, we just use a file with no \\n at all.\n"}
 {"Action":"output","Output":"BenchmarkFoo   \t"}
 {"Action":"output","Output":"10000 early EOF"}
-{"Action":"fail"}
+{"Action":"pass"}
diff --git a/src/cmd/internal/test2json/testdata/empty.json b/src/cmd/internal/test2json/testdata/empty.json
new file mode 100644 (file)
index 0000000..80b5217
--- /dev/null
@@ -0,0 +1 @@
+{"Action":"pass"}
diff --git a/src/cmd/internal/test2json/testdata/empty.test b/src/cmd/internal/test2json/testdata/empty.test
new file mode 100644 (file)
index 0000000..e69de29