mirror of https://github.com/stretchr/testify.git
suite: refactor methodFilter
Use strings.HasPrefix instead of a /^Test/ regexp (compiled on every call).suite-faster-methodFilter
parent
edb801534f
commit
48df1ec684
|
@ -7,6 +7,7 @@ import (
|
|||
"reflect"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -223,7 +224,7 @@ func Run(t *testing.T, suite TestingSuite) {
|
|||
// Filtering method according to set regular expression
|
||||
// specified command-line argument -m
|
||||
func methodFilter(name string) (bool, error) {
|
||||
if ok, _ := regexp.MatchString("^Test", name); !ok {
|
||||
if !strings.HasPrefix(name, "Test") {
|
||||
return false, nil
|
||||
}
|
||||
return regexp.MatchString(*matchMethod, name)
|
||||
|
|
Loading…
Reference in New Issue