Skip to content

Commit 0c86b99

Browse files
cmd/test2json: document passing -test.paniconexit0
For #29062 Fixes #43263 Change-Id: I160197c94cc4f936967cc22c82cec01663a14fe6 Reviewed-on: https://go-review.googlesource.com/c/go/+/283873 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 9135795 commit 0c86b99

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ go test -list=. ./main_zero
5454
stdout 'skipping all tests'
5555
! stdout TestNotListed
5656

57+
# Running the test directly still fails, if we pass the flag.
58+
go test -c -o ./zero.exe ./zero
59+
! exec ./zero.exe -test.paniconexit0
60+
61+
# Using -json doesn't affect the exit status.
62+
! go test -json ./zero
63+
! stdout '"Output":"ok'
64+
! stdout 'exit status'
65+
stdout 'panic'
66+
stdout '"Output":"FAIL'
67+
68+
# Running the test via test2json also fails.
69+
! go tool test2json ./zero.exe -test.v -test.paniconexit0
70+
! stdout '"Output":"ok'
71+
! stdout 'exit status'
72+
stdout 'panic'
73+
5774
-- go.mod --
5875
module m
5976

src/cmd/test2json/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Usage:
88
//
9-
// go tool test2json [-p pkg] [-t] [./pkg.test -test.v]
9+
// go tool test2json [-p pkg] [-t] [./pkg.test -test.v [-test.paniconexit0]]
1010
//
1111
// Test2json runs the given test command and converts its output to JSON;
1212
// with no command specified, test2json expects test output on standard input.
@@ -18,6 +18,10 @@
1818
//
1919
// The -t flag requests that time stamps be added to each test event.
2020
//
21+
// The test must be invoked with -test.v. Additionally passing
22+
// -test.paniconexit0 will cause test2json to exit with a non-zero
23+
// status if one of the tests being run calls os.Exit(0).
24+
//
2125
// Note that test2json is only intended for converting a single test
2226
// binary's output. To convert the output of a "go test" command,
2327
// use "go test -json" instead of invoking test2json directly.

0 commit comments

Comments
 (0)