MCPcopy Create free account
hub / github.com/bracesdev/errtrace / TestGetCallerWrap_RetCaller

Function TestGetCallerWrap_RetCaller

wrap_caller_test.go:64–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestGetCallerWrap_RetCaller(t *testing.T) {
65 err := callRetCaller()
66
67 wantFn := "callRetCaller"
68 if !safe {
69 // If the function calling pc.GetCaller is inlined, there's no stack frame
70 // so the assembly implementation can skip the correct caller.
71 // Callers of GetCaller using `go:noinline` avoid this (as recommended in the docs).
72 // Inlining is not consistent, hence we check the frame in !safe mode.
73 f, _, _ := errtrace.UnwrapFrame(err)
74 if !strings.HasSuffix(f.Function, wantFn) {
75 wantFn = "TestGetCallerWrap_RetCaller"
76 }
77 }
78 wantErr(t, err, wantFn)
79}
80
81func callRetCaller() error {
82 return retCaller().Wrap(errFoo)

Callers

nothing calls this directly

Calls 3

UnwrapFrameFunction · 0.92
callRetCallerFunction · 0.85
wantErrFunction · 0.85

Tested by

no test coverage detected