@@ -3,7 +3,6 @@ package stack_test
3
3
import (
4
4
"fmt"
5
5
"io/ioutil"
6
- "os"
7
6
"path"
8
7
"path/filepath"
9
8
"runtime"
@@ -12,6 +11,8 @@ import (
12
11
"gopkg.in/stack.v0"
13
12
)
14
13
14
+ const importPath = "github.com/go-stack/stack"
15
+
15
16
type testType struct {}
16
17
17
18
func (tt testType ) testMethod () (c stack.Call , pc uintptr , file string , line int , ok bool ) {
@@ -30,23 +31,13 @@ func TestCallFormat(t *testing.T) {
30
31
if ! ok {
31
32
t .Fatal ("runtime.Caller(0) failed" )
32
33
}
33
-
34
- gopathSrc := filepath .Join (os .Getenv ("GOPATH" ), "src" )
35
- relFile , err := filepath .Rel (gopathSrc , file )
36
- if err != nil {
37
- t .Fatalf ("failed to determine path relative to GOPATH: %v" , err )
38
- }
39
- relFile = filepath .ToSlash (relFile )
34
+ relFile := path .Join (importPath , filepath .Base (file ))
40
35
41
36
c2 , pc2 , file2 , line2 , ok2 := testType {}.testMethod ()
42
37
if ! ok2 {
43
38
t .Fatal ("runtime.Caller(0) failed" )
44
39
}
45
- relFile2 , err := filepath .Rel (gopathSrc , file )
46
- if err != nil {
47
- t .Fatalf ("failed to determine path relative to GOPATH: %v" , err )
48
- }
49
- relFile2 = filepath .ToSlash (relFile2 )
40
+ relFile2 := path .Join (importPath , filepath .Base (file2 ))
50
41
51
42
data := []struct {
52
43
c stack.Call
0 commit comments