suite: refactor methodFilter

Use strings.HasPrefix instead of a /^Test/ regexp (compiled on every call).
suite-faster-methodFilter
Olivier Mengué 2024-03-06 01:24:45 +01:00
parent edb801534f
commit 48df1ec684
1 changed files with 2 additions and 1 deletions

View File

@ -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)