-
-
Notifications
You must be signed in to change notification settings - Fork 464
fix(anr): Always report stacktraces for ANRv1 #4918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
24561c8
656c9fd
c62ce5c
00442b2
e1bbde4
fd123d2
cd1764f
2662674
b54acd5
b0cd87d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,9 @@ import kotlin.test.assertTrue | |
|
|
||
| class SentryThreadFactoryTest { | ||
| class Fixture { | ||
| internal fun getSut(attachStacktrace: Boolean = true) = | ||
| internal fun getSut() = | ||
| SentryThreadFactory( | ||
| SentryStackTraceFactory(SentryOptions().apply { addInAppExclude("io.sentry") }), | ||
| with(SentryOptions()) { | ||
| isAttachStacktrace = attachStacktrace | ||
| this | ||
| }, | ||
| SentryStackTraceFactory(SentryOptions().apply { addInAppExclude("io.sentry") }) | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -25,34 +21,37 @@ class SentryThreadFactoryTest { | |
| @Test | ||
| fun `when getCurrentThreads is called, not empty result`() { | ||
| val sut = fixture.getSut() | ||
| val threads = sut.getCurrentThreads(null) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that should be fine, we have some tests for extra covering the |
||
| val threads = sut.getCurrentThreads(null, false) | ||
| assertNotEquals(0, threads!!.count()) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when currentThreads is called, current thread is marked crashed`() { | ||
| val sut = fixture.getSut() | ||
| assertEquals(1, sut.getCurrentThreads(null)!!.filter { it.isCrashed == true }.count()) | ||
| assertEquals(1, sut.getCurrentThreads(null, false)!!.filter { it.isCrashed == true }.count()) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when currentThreads is called with ignoreCurrentThread, current thread is not marked crashed`() { | ||
| val sut = fixture.getSut() | ||
| assertEquals(0, sut.getCurrentThreads(null, true)!!.filter { it.isCrashed == true }.count()) | ||
| assertEquals( | ||
| 0, | ||
| sut.getCurrentThreads(null, true, false)!!.filter { it.isCrashed == true }.count(), | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when currentThreads is called, thread state is captured`() { | ||
| val sut = fixture.getSut() | ||
| assertTrue(sut.getCurrentThreads(null)!!.all { it.state != null }) | ||
| assertTrue(sut.getCurrentThreads(null, false)!!.all { it.state != null }) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when currentThreads is called, some thread stack frames are captured`() { | ||
| val sut = fixture.getSut() | ||
| assertTrue( | ||
| sut | ||
| .getCurrentThreads(null)!! | ||
| .getCurrentThreads(null, true)!! | ||
| .filter { it.stacktrace != null } | ||
| .any { it.stacktrace!!.frames!!.count() > 0 } | ||
| ) | ||
|
|
@@ -63,18 +62,18 @@ class SentryThreadFactoryTest { | |
| val sut = fixture.getSut() | ||
| assertTrue( | ||
| sut | ||
| .getCurrentThreads(null)!! | ||
| .getCurrentThreads(null, true)!! | ||
| .filter { it.stacktrace != null } | ||
| .any { it.stacktrace!!.snapshot == true } | ||
| ) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when currentThreads and attachStacktrace is disabled, stack frames are not captured`() { | ||
| val sut = fixture.getSut(false) | ||
| val sut = fixture.getSut() | ||
| assertFalse( | ||
| sut | ||
| .getCurrentThreads(null)!! | ||
| .getCurrentThreads(null, false)!! | ||
| .filter { it.stacktrace != null } | ||
| .any { it.stacktrace!!.frames!!.count() > 0 } | ||
| ) | ||
|
|
@@ -87,15 +86,15 @@ class SentryThreadFactoryTest { | |
| val currentThread = Thread.currentThread() | ||
| stackTraces.remove(currentThread) | ||
|
|
||
| val threads = sut.getCurrentThreads(stackTraces, null, false) | ||
| val threads = sut.getCurrentThreads(stackTraces, null, false, false) | ||
|
|
||
| assertNotNull(threads!!.firstOrNull { it.id == currentThread.id }) | ||
| } | ||
|
|
||
| @Test | ||
| fun `When passing empty param to getCurrentThreads, returns null`() { | ||
| val sut = fixture.getSut() | ||
| val threads = sut.getCurrentThreads(mapOf(), null, false) | ||
| val threads = sut.getCurrentThreads(mapOf(), null, false, false) | ||
|
|
||
| assertNull(threads) | ||
| } | ||
|
|
@@ -108,15 +107,15 @@ class SentryThreadFactoryTest { | |
| val stacktraces = emptyArray<StackTraceElement>() | ||
| val threadList = mutableMapOf(thread to stacktraces) | ||
|
|
||
| val threads = sut.getCurrentThreads(threadList, threadIds, false) | ||
| val threads = sut.getCurrentThreads(threadList, threadIds, false, false) | ||
|
|
||
| assertNotNull(threads!!.firstOrNull { it.isCrashed == true }) | ||
| } | ||
|
|
||
| @Test | ||
| fun `when getCurrentThread is called, returns current thread`() { | ||
| val sut = fixture.getSut() | ||
| val threads = sut.currentThread | ||
| val threads = sut.getCurrentThread(false) | ||
| assertEquals(1, threads!!.count()) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.