mirror of https://github.com/stretchr/testify.git
Merge pull request #221 from brahmaroutu/gccgo_functionname_issue
Due to function name format differences, code fails with GCCGOpull/223/head
commit
2b15294402
|
@ -3,6 +3,7 @@ package mock
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -265,6 +266,14 @@ func (m *Mock) Called(arguments ...interface{}) Arguments {
|
||||||
panic("Couldn't get the caller information")
|
panic("Couldn't get the caller information")
|
||||||
}
|
}
|
||||||
functionPath := runtime.FuncForPC(pc).Name()
|
functionPath := runtime.FuncForPC(pc).Name()
|
||||||
|
//Next four lines are required to use GCCGO function naming conventions.
|
||||||
|
//For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock
|
||||||
|
//uses inteface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree
|
||||||
|
//With GCCGO we need to remove interface information starting from pN<dd>.
|
||||||
|
re := regexp.MustCompile("\\.pN\\d+_")
|
||||||
|
if re.MatchString(functionPath) {
|
||||||
|
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