1 [short] skip
2
3 # test fail fast
4 ! go test ./failfast_test.go -run='TestFailingA' -failfast=true
5 stdout -count=1 'FAIL - '
6 ! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=true
7 stdout -count=1 'FAIL - '
8 ! go test ./failfast_test.go -run='TestFailing[AB]' -failfast=false
9 stdout -count=2 'FAIL - '
10
11 # mix with non-failing tests
12 ! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=true
13 stdout -count=1 'FAIL - '
14 ! go test ./failfast_test.go -run='TestA|TestFailing[AB]' -failfast=false
15 stdout -count=2 'FAIL - '
16
17 # mix with parallel tests
18 ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=true
19 stdout -count=2 'FAIL - '
20 ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailingA' -failfast=false
21 stdout -count=2 'FAIL - '
22 ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=true
23 stdout -count=3 'FAIL - '
24 ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]' -failfast=false
25 stdout -count=3 'FAIL - '
26
27 # mix with parallel sub-tests
28 ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=true
29 stdout -count=3 'FAIL - '
30 ! go test ./failfast_test.go -run='TestFailingB|TestParallelFailing[AB]|TestParallelFailingSubtestsA' -failfast=false
31 stdout -count=5 'FAIL - '
32 ! go test ./failfast_test.go -run='TestParallelFailingSubtestsA' -failfast=true
33 stdout -count=1 'FAIL - '
34
35 # only parallels
36 ! go test ./failfast_test.go -run='TestParallelFailing[AB]' -failfast=false
37 stdout -count=2 'FAIL - '
38
39 # non-parallel subtests
40 ! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=true
41 stdout -count=1 'FAIL - '
42 ! go test ./failfast_test.go -run='TestFailingSubtestsA' -failfast=false
43 stdout -count=2 'FAIL - '
44
45 # fatal test
46 ! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=true
47 stdout -count=1 'FAIL - '
48 ! go test ./failfast_test.go -run='TestFatal[CD]' -failfast=false
49 stdout -count=2 'FAIL - '
50
51 # cross package failfast
52 ! go test -p 1 -failfast ./a ./b ./c
53 stdout -count=1 'FAIL - '
54 stdout -count=1 'FAIL - TestFailingPkgA'
55
56 -- go.mod --
57 module m
58
59 go 1.21.0
60 -- failfast_test.go --
61 // Copyright 2017 The Go Authors. All rights reserved.
62 // Use of this source code is governed by a BSD-style
63 // license that can be found in the LICENSE file.
64
65 package failfast
66
67 import "testing"
68
69 func TestA(t *testing.T) {
70 // Edge-case testing, mixing unparallel tests too
71 t.Logf("LOG: %s", t.Name())
72 }
73
74 func TestFailingA(t *testing.T) {
75 t.Errorf("FAIL - %s", t.Name())
76 }
77
78 func TestB(t *testing.T) {
79 // Edge-case testing, mixing unparallel tests too
80 t.Logf("LOG: %s", t.Name())
81 }
82
83 func TestParallelFailingA(t *testing.T) {
84 t.Parallel()
85 t.Errorf("FAIL - %s", t.Name())
86 }
87
88 func TestParallelFailingB(t *testing.T) {
89 t.Parallel()
90 t.Errorf("FAIL - %s", t.Name())
91 }
92
93 func TestParallelFailingSubtestsA(t *testing.T) {
94 t.Parallel()
95 t.Run("TestFailingSubtestsA1", func(t *testing.T) {
96 t.Errorf("FAIL - %s", t.Name())
97 })
98 t.Run("TestFailingSubtestsA2", func(t *testing.T) {
99 t.Errorf("FAIL - %s", t.Name())
100 })
101 }
102
103 func TestFailingSubtestsA(t *testing.T) {
104 t.Run("TestFailingSubtestsA1", func(t *testing.T) {
105 t.Errorf("FAIL - %s", t.Name())
106 })
107 t.Run("TestFailingSubtestsA2", func(t *testing.T) {
108 t.Errorf("FAIL - %s", t.Name())
109 })
110 }
111
112 func TestFailingB(t *testing.T) {
113 t.Errorf("FAIL - %s", t.Name())
114 }
115
116 func TestFatalC(t *testing.T) {
117 t.Fatalf("FAIL - %s", t.Name())
118 }
119
120 func TestFatalD(t *testing.T) {
121 t.Fatalf("FAIL - %s", t.Name())
122 }
123 -- a/a_test.go --
124 package a
125
126 import "testing"
127
128 func TestFailingPkgA(t *testing.T) {
129 t.Errorf("FAIL - %s", t.Name())
130 }
131 -- b/b_test.go --
132 package b
133
134 import "testing"
135
136 func TestFailingPkgB(t *testing.T) {
137 t.Errorf("FAIL - %s", t.Name())
138 }
139 -- c/c_test.go --
140 package c
141
142 import "testing"
143
144 func TestFailingPkgC(t *testing.T) {
145 t.Errorf("FAIL - %s", t.Name())
146 }
147
View as plain text