Skip to content

Commit

Permalink
suite: refactor methodFilter
Browse files Browse the repository at this point in the history
Use strings.HasPrefix instead of a /^Test/ regexp (compiled on every call).
  • Loading branch information
dolmen committed Mar 6, 2024
1 parent edb8015 commit 48df1ec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion suite/suite.go
Expand Up @@ -7,6 +7,7 @@ import (
"reflect"
"regexp"
"runtime/debug"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 48df1ec

Please sign in to comment.