From 48df1ec6843ca31a952a4e796cd2afeccc2a14c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Wed, 6 Mar 2024 01:24:45 +0100 Subject: [PATCH] suite: refactor methodFilter Use strings.HasPrefix instead of a /^Test/ regexp (compiled on every call). --- suite/suite.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/suite/suite.go b/suite/suite.go index 18443a9..79006aa 100644 --- a/suite/suite.go +++ b/suite/suite.go @@ -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)