@@ -140,16 +140,24 @@ func Run(t *testing.T, suite TestingSuite) {
140140 methodFinder := reflect .TypeOf (suite )
141141 suiteName := methodFinder .Elem ().Name ()
142142
143- for i := 0 ; i < methodFinder . NumMethod (); i ++ {
144- method := methodFinder . Method ( i )
145-
146- ok , err := methodFilter ( method . Name )
143+ var matchMethodRE * regexp. Regexp
144+ if * matchMethod != "" {
145+ var err error
146+ matchMethodRE , err = regexp . Compile ( * matchMethod )
147147 if err != nil {
148148 fmt .Fprintf (os .Stderr , "testify: invalid regexp for -m: %s\n " , err )
149149 os .Exit (1 )
150150 }
151+ }
152+
153+ for i := 0 ; i < methodFinder .NumMethod (); i ++ {
154+ method := methodFinder .Method (i )
151155
152- if ! ok {
156+ if ! strings .HasPrefix (method .Name , "Test" ) {
157+ continue
158+ }
159+ // Apply -testify.m filter
160+ if matchMethodRE != nil && ! matchMethodRE .MatchString (method .Name ) {
153161 continue
154162 }
155163
@@ -225,15 +233,6 @@ func Run(t *testing.T, suite TestingSuite) {
225233 runTests (t , tests )
226234}
227235
228- // Filtering method according to set regular expression
229- // specified command-line argument -m
230- func methodFilter (name string ) (bool , error ) {
231- if ! strings .HasPrefix (name , "Test" ) {
232- return false , nil
233- }
234- return regexp .MatchString (* matchMethod , name )
235- }
236-
237236func runTests (t * testing.T , tests []test ) {
238237 if len (tests ) == 0 {
239238 t .Log ("warning: no tests to run" )
0 commit comments