...
1# Verifies golang.org/issue/37555.
2
3[short] skip
4
5# 'go test -json' should say a test passes if it says it passes.
6go test -json ./pass
7stdout '"Action":"pass","Package":"[^"]*","Elapsed":[^"]*}\n\z'
8! stdout '"Test":.*\n\z'
9
10# 'go test -json' should say a test passes if it exits 0 and prints nothing.
11# TODO(golang.org/issue/29062): this should fail in the future.
12go test -json ./exit0main
13stdout '"Action":"pass".*\n\z'
14! stdout '"Test":.*\n\z'
15
16# 'go test -json' should say a test fails if it exits 1 and prints nothing.
17! go test -json ./exit1main
18stdout '"Action":"fail".*\n\z'
19! stdout '"Test":.*\n\z'
20
21# 'go test -json' should say a test fails if it panics.
22! go test -json ./panic
23stdout '"Action":"fail".*\n\z'
24! stdout '"Test":.*\n\z'
25
26-- go.mod --
27module example.com/test
28
29go 1.14
30
31-- pass/pass_test.go --
32package pass_test
33
34import "testing"
35
36func TestPass(t *testing.T) {}
37
38-- exit0main/exit0main_test.go --
39package exit0_test
40
41import (
42 "os"
43 "testing"
44)
45
46func TestMain(m *testing.M) {
47 os.Exit(0)
48}
49
50-- exit1main/exit1main_test.go --
51package exit1_test
52
53import (
54 "os"
55 "testing"
56)
57
58func TestMain(m *testing.M) {
59 os.Exit(1)
60}
61
62-- panic/panic_test.go --
63package panic_test
64
65import "testing"
66
67func TestPanic(t *testing.T) {
68 panic("oh no")
69}
View as plain text