mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
suite: refactor methodFilter
Use strings.HasPrefix instead of a /^Test/ regexp (compiled on every call).
This commit is contained in:
parent
0ff4bb43de
commit
2fd71d2349
@ -7,6 +7,7 @@ import (
|
||||
"reflect"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@ -227,7 +228,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…
x
Reference in New Issue
Block a user