diff options
Diffstat (limited to 'internal/lazyregexp/lazyre.go')
-rw-r--r-- | internal/lazyregexp/lazyre.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/internal/lazyregexp/lazyre.go b/internal/lazyregexp/lazyre.go index 79ce5a18..e4c9f7ea 100644 --- a/internal/lazyregexp/lazyre.go +++ b/internal/lazyregexp/lazyre.go @@ -7,10 +7,10 @@ package lazyregexp import ( - "os" "regexp" - "strings" "sync" + + "gogs.io/gogs/internal/testutil" ) // Regexp is a wrapper around regexp.Regexp, where the underlying regexp will be @@ -99,14 +99,12 @@ func (r *Regexp) ReplaceAll(src, repl []byte) []byte { return r.Regexp().ReplaceAll(src, repl) } -var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") - // New creates a new lazy regexp, delaying the compiling work until it is first // needed. If the code is being run as part of tests, the regexp compiling will // happen immediately. func New(str string) *Regexp { lr := &Regexp{str: str} - if inTest { + if testutil.InTest { // In tests, always compile the regexps early. lr.Regexp() } |