MCPcopy Index your code
hub / github.com/maruel/panicparse / TestScanSnapshotSyntheticTwoSnapshots

Function TestScanSnapshotSyntheticTwoSnapshots

stack/context_test.go:1336–1418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1334}
1335
1336func TestScanSnapshotSyntheticTwoSnapshots(t *testing.T) {
1337 t.Parallel()
1338 in := bytes.Buffer{}
1339 in.WriteString("Ya\n")
1340 in.Write(internaltest.PanicOutputs()["simple"])
1341 in.WriteString("Ye\n")
1342 in.Write(internaltest.PanicOutputs()["int"])
1343 in.WriteString("Yo\n")
1344 panicParseDir := getPanicParseDir(t)
1345 ppDir := pathJoin(panicParseDir, "cmd", "panic")
1346
1347 // First stack:
1348 prefix := bytes.Buffer{}
1349 s, suffix, err := ScanSnapshot(&in, &prefix, defaultOpts())
1350 compareErr(t, nil, err)
1351 if !s.guessPaths() {
1352 t.Error("expected success")
1353 }
1354 want := []*Goroutine{
1355 {
1356 Signature: Signature{
1357 State: "running",
1358 Stack: Stack{
1359 Calls: []Call{
1360 newCallLocal(
1361 "main.main",
1362 Args{},
1363 pathJoin(ppDir, "main.go"),
1364 74,
1365 ),
1366 },
1367 },
1368 },
1369 ID: 1,
1370 First: true,
1371 },
1372 }
1373 compareGoroutines(t, want, s.Goroutines)
1374 compareString(t, "Ya\nGOTRACEBACK=all\npanic: simple\n\n", prefix.String())
1375
1376 prefix.Reset()
1377 r := io.MultiReader(bytes.NewReader(suffix), &in)
1378 s, suffix, err = ScanSnapshot(r, &prefix, defaultOpts())
1379 compareErr(t, nil, err)
1380 if !s.guessPaths() {
1381 t.Error("expected success")
1382 }
1383 // This is a change detector on internal/main.go.
1384 want = []*Goroutine{
1385 {
1386 Signature: Signature{
1387 State: "running",
1388 Stack: Stack{
1389 Calls: []Call{
1390 newCallLocal(
1391 "main.panicint",
1392 Args{Values: []Arg{{Value: 42}}},
1393 pathJoin(ppDir, "main.go"),

Callers

nothing calls this directly

Calls 12

PanicOutputsFunction · 0.92
getPanicParseDirFunction · 0.85
pathJoinFunction · 0.85
ScanSnapshotFunction · 0.85
defaultOptsFunction · 0.85
compareErrFunction · 0.85
compareGoroutinesFunction · 0.85
WriteMethod · 0.80
guessPathsMethod · 0.80
newCallLocalFunction · 0.70
compareStringFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…