@@ -15,7 +15,6 @@ import (
15
15
"github.com/stretchr/testify/require"
16
16
)
17
17
18
- var allTestsFilter = func (_ , _ string ) (bool , error ) { return true , nil }
19
18
var matchMethod = flag .String ("testify.m" , "" , "regular expression to select tests of the testify suite to run" )
20
19
21
20
// Suite is a basic testing suite with methods for storing and
@@ -116,6 +115,11 @@ func (suite *Suite) Run(name string, subtest func()) bool {
116
115
})
117
116
}
118
117
118
+ type test = struct {
119
+ name string
120
+ run func (t * testing.T )
121
+ }
122
+
119
123
// Run takes a testing suite and runs all of the tests attached
120
124
// to it.
121
125
func Run (t * testing.T , suite TestingSuite ) {
@@ -131,7 +135,7 @@ func Run(t *testing.T, suite TestingSuite) {
131
135
stats = newSuiteInformation ()
132
136
}
133
137
134
- tests := []testing. InternalTest {}
138
+ var tests [] test
135
139
methodFinder := reflect .TypeOf (suite )
136
140
suiteName := methodFinder .Elem ().Name ()
137
141
@@ -160,9 +164,9 @@ func Run(t *testing.T, suite TestingSuite) {
160
164
suiteSetupDone = true
161
165
}
162
166
163
- test := testing. InternalTest {
164
- Name : method .Name ,
165
- F : func (t * testing.T ) {
167
+ test := test {
168
+ name : method .Name ,
169
+ run : func (t * testing.T ) {
166
170
parentT := suite .T ()
167
171
suite .SetT (t )
168
172
defer recoverAndFailOnPanic (t )
@@ -229,25 +233,13 @@ func methodFilter(name string) (bool, error) {
229
233
return regexp .MatchString (* matchMethod , name )
230
234
}
231
235
232
- func runTests (t testing.TB , tests []testing. InternalTest ) {
236
+ func runTests (t * testing.T , tests []test ) {
233
237
if len (tests ) == 0 {
234
238
t .Log ("warning: no tests to run" )
235
239
return
236
240
}
237
241
238
- r , ok := t .(runner )
239
- if ! ok { // backwards compatibility with Go 1.6 and below
240
- if ! testing .RunTests (allTestsFilter , tests ) {
241
- t .Fail ()
242
- }
243
- return
244
- }
245
-
246
242
for _ , test := range tests {
247
- r .Run (test .Name , test .F )
243
+ t .Run (test .name , test .run )
248
244
}
249
245
}
250
-
251
- type runner interface {
252
- Run (name string , f func (t * testing.T )) bool
253
- }
0 commit comments