...
1go test -json
2
3stdout '"Action":"output","Package":"p","Output":"M1"}'
4stdout '"Action":"output","Package":"p","Test":"Test","Output":"=== RUN Test\\n"}'
5stdout '"Action":"output","Package":"p","Test":"Test","Output":"T1"}'
6stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"=== RUN Test/Sub1\\n"}'
7stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"Sub1 x_test.go:19: SubLog1\\n"}'
8stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"Sub2"}'
9stdout '"Action":"output","Package":"p","Test":"Test/Sub1","Output":"--- PASS: Test/Sub1 \([\d.]+s\)\\n"}'
10stdout '"Action":"pass","Package":"p","Test":"Test/Sub1","Elapsed"'
11stdout '"Action":"output","Package":"p","Test":"Test/Sub3","Output":"foo bar"}'
12stdout '"Action":"output","Package":"p","Test":"Test/Sub3","Output":"baz\\n"}'
13stdout '"Action":"output","Package":"p","Test":"Test","Output":"T2"}'
14stdout '"Action":"output","Package":"p","Test":"Test","Output":"--- PASS: Test \([\d.]+s\)\\n"}'
15stdout '"Action":"pass","Package":"p","Test":"Test","Elapsed"'
16stdout '"Action":"output","Package":"p","Output":"M2ok \\tp\\t[\d.]+s\\n"}'
17stdout '"Action":"pass","Package":"p","Elapsed"'
18
19-- go.mod --
20module p
21
22-- x_test.go --
23package p
24
25import (
26 "os"
27 "testing"
28)
29
30func TestMain(m *testing.M) {
31 print("M1")
32 code := m.Run()
33 print("M2")
34 os.Exit(code)
35}
36
37func Test(t *testing.T) {
38 print("T1")
39 t.Run("Sub1", func(t *testing.T) {
40 print("Sub1")
41 t.Log("SubLog1")
42 print("Sub2")
43 })
44 t.Run("Sub3", func(t *testing.T) {
45 print("\x16foo bar\x16baz\n")
46 })
47 print("T2")
48}
View as plain text