@@ -138,16 +138,24 @@ func Run(t *testing.T, suite TestingSuite) {
138
138
methodFinder := reflect .TypeOf (suite )
139
139
suiteName := methodFinder .Elem ().Name ()
140
140
141
- for i := 0 ; i < methodFinder . NumMethod (); i ++ {
142
- method := methodFinder . Method ( i )
143
-
144
- ok , err := methodFilter ( method . Name )
141
+ var matchMethodRE * regexp. Regexp
142
+ if * matchMethod != "" {
143
+ var err error
144
+ matchMethodRE , err = regexp . Compile ( * matchMethod )
145
145
if err != nil {
146
146
fmt .Fprintf (os .Stderr , "testify: invalid regexp for -m: %s\n " , err )
147
147
os .Exit (1 )
148
148
}
149
+ }
150
+
151
+ for i := 0 ; i < methodFinder .NumMethod (); i ++ {
152
+ method := methodFinder .Method (i )
149
153
150
- if ! ok {
154
+ if ! strings .HasPrefix (method .Name , "Test" ) {
155
+ continue
156
+ }
157
+ // Apply -testify.m filter
158
+ if matchMethodRE != nil && ! matchMethodRE .MatchString (method .Name ) {
151
159
continue
152
160
}
153
161
@@ -217,15 +225,6 @@ func Run(t *testing.T, suite TestingSuite) {
217
225
runTests (t , tests )
218
226
}
219
227
220
- // Filtering method according to set regular expression
221
- // specified command-line argument -m
222
- func methodFilter (name string ) (bool , error ) {
223
- if ! strings .HasPrefix (name , "Test" ) {
224
- return false , nil
225
- }
226
- return regexp .MatchString (* matchMethod , name )
227
- }
228
-
229
228
func runTests (t * testing.T , tests []test ) {
230
229
if len (tests ) == 0 {
231
230
t .Log ("warning: no tests to run" )
0 commit comments