mirror of https://github.com/stretchr/testify.git
mock: move regexp compilation outside of Called (#631)
Co-authored-by: Olivier Mengué <dolmen@cpan.org>pull/1445/head
parent
a392378178
commit
a23f5db224
|
@ -18,6 +18,9 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// regex for GCCGO functions
|
||||||
|
var gccgoRE = regexp.MustCompile(`\.pN\d+_`)
|
||||||
|
|
||||||
// TestingT is an interface wrapper around *testing.T
|
// TestingT is an interface wrapper around *testing.T
|
||||||
type TestingT interface {
|
type TestingT interface {
|
||||||
Logf(format string, args ...interface{})
|
Logf(format string, args ...interface{})
|
||||||
|
@ -455,9 +458,8 @@ func (m *Mock) Called(arguments ...interface{}) Arguments {
|
||||||
// For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
|
// For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
|
||||||
// uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
|
// uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
|
||||||
// With GCCGO we need to remove interface information starting from pN<dd>.
|
// With GCCGO we need to remove interface information starting from pN<dd>.
|
||||||
re := regexp.MustCompile("\\.pN\\d+_")
|
if gccgoRE.MatchString(functionPath) {
|
||||||
if re.MatchString(functionPath) {
|
functionPath = gccgoRE.Split(functionPath, -1)[0]
|
||||||
functionPath = re.Split(functionPath, -1)[0]
|
|
||||||
}
|
}
|
||||||
parts := strings.Split(functionPath, ".")
|
parts := strings.Split(functionPath, ".")
|
||||||
functionName := parts[len(parts)-1]
|
functionName := parts[len(parts)-1]
|
||||||
|
|
Loading…
Reference in New Issue