Skip to content

Commit 7d37b5c

Browse files
committed
suite: refactor methodFilter
Use strings.HasPrefix instead of a /^Test/ regexp (compiled on every call).
1 parent c58bc90 commit 7d37b5c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

suite/suite.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"reflect"
88
"regexp"
99
"runtime/debug"
10+
"strings"
1011
"sync"
1112
"testing"
1213
"time"
@@ -219,7 +220,7 @@ func Run(t *testing.T, suite TestingSuite) {
219220
// Filtering method according to set regular expression
220221
// specified command-line argument -m
221222
func methodFilter(name string) (bool, error) {
222-
if ok, _ := regexp.MatchString("^Test", name); !ok {
223+
if !strings.HasPrefix(name, "Test") {
223224
return false, nil
224225
}
225226
return regexp.MatchString(*matchMethod, name)

0 commit comments

Comments
 (0)