(fname string, t *testing.T)
| 258 | } |
| 259 | |
| 260 | func readProfile(fname string, t *testing.T) *profile.Profile { |
| 261 | file, err := os.Open(fname) |
| 262 | if err != nil { |
| 263 | t.Fatalf("%s: could not open profile: %v", fname, err) |
| 264 | } |
| 265 | defer file.Close() |
| 266 | p, err := profile.Parse(file) |
| 267 | if err != nil { |
| 268 | t.Fatalf("%s: could not parse profile: %v", fname, err) |
| 269 | } |
| 270 | |
| 271 | // Fix file names so they do not include absolute path names. |
| 272 | fix := func(s string) string { |
| 273 | const testdir = "/internal/report/" |
| 274 | pos := strings.Index(s, testdir) |
| 275 | if pos == -1 { |
| 276 | return s |
| 277 | } |
| 278 | return s[pos+len(testdir):] |
| 279 | } |
| 280 | for _, m := range p.Mapping { |
| 281 | m.File = fix(m.File) |
| 282 | } |
| 283 | for _, f := range p.Function { |
| 284 | f.Filename = fix(f.Filename) |
| 285 | } |
| 286 | |
| 287 | return p |
| 288 | } |
no test coverage detected
searching dependent graphs…