Skip to content

Commit 7416ffc

Browse files
test: Fix flaky thread inspector tests (#5836)
Considering the edge case when getting threads returns an empty list. This can happen when there are more than 70 threads in CI and is a known limitation. We don't need to let the tests flake for this.
1 parent 48e5c8a commit 7416ffc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Tests/SentryTests/SentryCrash/SentryThreadInspectorTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ class SentryThreadInspectorTests: XCTestCase {
6161
queue.async {
6262
let threads = sut.getCurrentThreadsWithStackTrace()
6363

64+
if threads.count == 0 {
65+
// If there are more than 70 threads getCurrentThreadsWithStackTrace
66+
// returns an empty list because it can't handle so many threads.
67+
// This is a known limitation SentryThreadInspector and should be
68+
// addressed in https://github.com/getsentry/sentry-cocoa/issues/2825.
69+
// We see this sometimes happening in CI.
70+
expect.fulfill()
71+
return
72+
}
73+
6474
var threadsWithStackTraceFrames = 0
6575

6676
for thread in threads {
@@ -111,6 +121,16 @@ class SentryThreadInspectorTests: XCTestCase {
111121
queue.async {
112122
let threads = sut.getCurrentThreadsWithStackTrace()
113123

124+
if threads.count == 0 {
125+
// If there are more than 70 threads getCurrentThreadsWithStackTrace
126+
// returns an empty list because it can't handle so many threads.
127+
// This is a known limitation SentryThreadInspector and should be
128+
// addressed in https://github.com/getsentry/sentry-cocoa/issues/2825.
129+
// We see this sometimes happening in CI.
130+
expect.fulfill()
131+
return
132+
}
133+
114134
var threadsWithStackTraceFrames = 0
115135

116136
for thread in threads {

0 commit comments

Comments
 (0)