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"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -223,7 +224,7 @@ func Run(t *testing.T, suite TestingSuite) {
|
||||||
// Filtering method according to set regular expression
|
// Filtering method according to set regular expression
|
||||||
// specified command-line argument -m
|
// specified command-line argument -m
|
||||||
func methodFilter(name string) (bool, error) {
|
func methodFilter(name string) (bool, error) {
|
||||||
if ok, _ := regexp.MatchString("^Test", name); !ok {
|
if !strings.HasPrefix(name, "Test") {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return regexp.MatchString(*matchMethod, name)
|
return regexp.MatchString(*matchMethod, name)
|
||||||
|
|
Loading…
Reference in New Issue