(t *testing.T, content []byte, mayBeInlined bool, want Stack)
| 1420 | } |
| 1421 | |
| 1422 | func testAugmentCommon(t *testing.T, content []byte, mayBeInlined bool, want Stack) { |
| 1423 | // Analyze it. |
| 1424 | prefix := bytes.Buffer{} |
| 1425 | s, suffix, err := ScanSnapshot(bytes.NewBuffer(content), &prefix, defaultOpts()) |
| 1426 | if err != nil { |
| 1427 | t.Fatalf("failed to parse input: %v", err) |
| 1428 | } |
| 1429 | if got := prefix.String(); got != "panic: ooh\n\n" { |
| 1430 | t.Fatalf("Unexpected panic output:\n%#v", got) |
| 1431 | } |
| 1432 | compareString(t, "exit status 2\n", string(suffix)) |
| 1433 | if !s.guessPaths() { |
| 1434 | t.Error("expected success") |
| 1435 | } |
| 1436 | |
| 1437 | if err := s.augment(); err != nil { |
| 1438 | t.Errorf("augment() returned %v", err) |
| 1439 | } |
| 1440 | got := s.Goroutines[0].Signature.Stack |
| 1441 | zapPointers(t, &want, &got) |
| 1442 | |
| 1443 | // With a non-pointer method, elided argument can be shown. It's only for |
| 1444 | // test case "non-pointer method". |
| 1445 | if mayBeInlined { |
| 1446 | for j := range got.Calls { |
| 1447 | if !want.Calls[j].Args.Elided { |
| 1448 | got.Calls[j].Args.Elided = false |
| 1449 | } |
| 1450 | if got.Calls[j].Args.Values == nil { |
| 1451 | want.Calls[j].Args.Values = nil |
| 1452 | } |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | if diff := cmp.Diff(want, got); diff != "" { |
| 1457 | t.Logf("Different (-want +got):\n%s", diff) |
| 1458 | t.Logf("Output:\n%s", content) |
| 1459 | t.FailNow() |
| 1460 | } |
| 1461 | } |
| 1462 | |
| 1463 | func TestAugmentErr(t *testing.T) { |
| 1464 | t.Parallel() |
no test coverage detected
searching dependent graphs…