(failTest bool, format string, args ...interface{})
| 179 | } |
| 180 | |
| 181 | func (t *T) failWithf(failTest bool, format string, args ...interface{}) { |
| 182 | t.Helper() |
| 183 | _, file, line, _ := runtime.Caller(2) |
| 184 | var msg bytes.Buffer |
| 185 | fmt.Fprintf(&msg, format, args...) |
| 186 | contextLines, lineIdx := fileContext(file, line, 1) |
| 187 | if len(contextLines) > 0 { |
| 188 | msg.WriteString("\ncontext:\n") |
| 189 | for i, line := range contextLines { |
| 190 | switch { |
| 191 | case i == lineIdx: |
| 192 | fmt.Fprintf(&msg, "> %s\n", line) |
| 193 | default: |
| 194 | fmt.Fprintf(&msg, " %s\n", line) |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | if failTest { |
| 199 | t.Fatal(msg.String()) |
| 200 | } else { |
| 201 | t.Error(msg.String()) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // The following code is copied from github.com/getsentry/raven-go. |
| 206 |
no test coverage detected