(t *testing.T)
| 62 | } |
| 63 | |
| 64 | func 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 | |
| 81 | func callRetCaller() error { |
| 82 | return retCaller().Wrap(errFoo) |
nothing calls this directly
no test coverage detected