File tree 2 files changed +22
-1
lines changed 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,23 @@ go test -list=. ./main_zero
54
54
stdout 'skipping all tests'
55
55
! stdout TestNotListed
56
56
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
+
57
74
-- go.mod --
58
75
module m
59
76
Original file line number Diff line number Diff line change 6
6
//
7
7
// Usage:
8
8
//
9
- // go tool test2json [-p pkg] [-t] [./pkg.test -test.v]
9
+ // go tool test2json [-p pkg] [-t] [./pkg.test -test.v [-test.paniconexit0] ]
10
10
//
11
11
// Test2json runs the given test command and converts its output to JSON;
12
12
// with no command specified, test2json expects test output on standard input.
18
18
//
19
19
// The -t flag requests that time stamps be added to each test event.
20
20
//
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
+ //
21
25
// Note that test2json is only intended for converting a single test
22
26
// binary's output. To convert the output of a "go test" command,
23
27
// use "go test -json" instead of invoking test2json directly.
You can’t perform that action at this time.
0 commit comments