]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/test2json: document passing -test.paniconexit0
authorIan Lance Taylor <iant@golang.org>
Thu, 14 Jan 2021 20:00:23 +0000 (12:00 -0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 14 Jan 2021 20:38:03 +0000 (20:38 +0000)
For #29062
Fixes #43263

Change-Id: I160197c94cc4f936967cc22c82cec01663a14fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/283873
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/go/testdata/script/test_exit.txt
src/cmd/test2json/main.go

index 23a2429d1ecaaaa9d7b8ab50cb975a34c6a9e386..3703ba53d362b0b0930cde8aa2ff233c5eee9934 100644 (file)
@@ -54,6 +54,23 @@ go test -list=. ./main_zero
 stdout 'skipping all tests'
 ! stdout TestNotListed
 
+# Running the test directly still fails, if we pass the flag.
+go test -c -o ./zero.exe ./zero
+! exec ./zero.exe -test.paniconexit0
+
+# Using -json doesn't affect the exit status.
+! go test -json ./zero
+! stdout '"Output":"ok'
+! stdout 'exit status'
+stdout 'panic'
+stdout '"Output":"FAIL'
+
+# Running the test via test2json also fails.
+! go tool test2json ./zero.exe -test.v -test.paniconexit0
+! stdout '"Output":"ok'
+! stdout 'exit status'
+stdout 'panic'
+
 -- go.mod --
 module m
 
index 57a874193e311cb19797dee89f16055fde81edeb..e40881ab3fc1ebe73e2769db5551b54e2383277e 100644 (file)
@@ -6,7 +6,7 @@
 //
 // Usage:
 //
-//     go tool test2json [-p pkg] [-t] [./pkg.test -test.v]
+//     go tool test2json [-p pkg] [-t] [./pkg.test -test.v [-test.paniconexit0]]
 //
 // Test2json runs the given test command and converts its output to JSON;
 // with no command specified, test2json expects test output on standard input.
 //
 // The -t flag requests that time stamps be added to each test event.
 //
+// The test must be invoked with -test.v. Additionally passing
+// -test.paniconexit0 will cause test2json to exit with a non-zero
+// status if one of the tests being run calls os.Exit(0).
+//
 // Note that test2json is only intended for converting a single test
 // binary's output. To convert the output of a "go test" command,
 // use "go test -json" instead of invoking test2json directly.