Skip to content

Commit ea2a9ce

Browse files
committed
adapt parseTombstoneWithJavaFunctionName in TombstoneParserTest to epitaph and make the snapshot test independent of order.
1 parent f52eb9c commit ea2a9ce

File tree

3 files changed

+22
-31
lines changed

3 files changed

+22
-31
lines changed

sentry-android-core/src/test/java/io/sentry/android/core/internal/tombstone/TombstoneParserTest.kt

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -440,39 +440,29 @@ class TombstoneParserTest {
440440

441441
private fun parseTombstoneWithJavaFunctionName(functionName: String): io.sentry.SentryEvent {
442442
val tombstone =
443-
TombstoneProtos.Tombstone.newBuilder()
444-
.setPid(1234)
445-
.setTid(1234)
446-
.setSignalInfo(
447-
TombstoneProtos.Signal.newBuilder()
448-
.setNumber(11)
449-
.setName("SIGSEGV")
450-
.setCode(1)
451-
.setCodeName("SEGV_MAPERR")
452-
)
453-
.putThreads(
454-
1234,
455-
TombstoneProtos.Thread.newBuilder()
456-
.setId(1234)
457-
.setName("main")
458-
.addCurrentBacktrace(
459-
TombstoneProtos.BacktraceFrame.newBuilder()
460-
.setPc(0x1000)
461-
.setFunctionName(functionName)
462-
.setFileName("/data/app/base.apk!classes.oat")
463-
)
464-
.build(),
443+
Tombstone.Builder()
444+
.pid(1234)
445+
.tid(1234)
446+
.signal(Signal(11, "SIGSEGV", 1, "SEGV_MAPERR", false, 0, 0, false, 0, null))
447+
.addThread(
448+
TombstoneThread(
449+
1234,
450+
"main",
451+
emptyList(),
452+
emptyList(),
453+
emptyList(),
454+
listOf(
455+
BacktraceFrame(0, 0x1000, 0, functionName, 0, "/data/app/base.apk!classes.oat", 0, "")
456+
),
457+
emptyList(),
458+
0,
459+
0,
460+
)
465461
)
466462
.build()
467463

468-
val parser =
469-
TombstoneParser(
470-
ByteArrayInputStream(tombstone.toByteArray()),
471-
inAppIncludes,
472-
inAppExcludes,
473-
nativeLibraryDir,
474-
)
475-
return parser.parse()
464+
val parser = TombstoneParser(inAppIncludes, inAppExcludes, nativeLibraryDir)
465+
return parser.parse(tombstone)
476466
}
477467

478468
private fun assertTombstoneParsesCorrectly(tombstoneResource: String) {
@@ -555,7 +545,8 @@ class TombstoneParserTest {
555545
val writer = StringWriter()
556546
val jsonWriter = JsonObjectWriter(writer, 100)
557547
jsonWriter.beginObject()
558-
for (thread in event.threads!!) {
548+
// Sort threads by ID for deterministic output (epitaph uses HashMap for threads)
549+
for (thread in event.threads!!.sortedBy { it.id }) {
559550
val javaFrames = thread.stacktrace!!.frames!!.filter { it.platform == "java" }
560551
if (javaFrames.isEmpty()) continue
561552
jsonWriter.name(thread.id.toString())
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)