File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Tests/SentryTests/SentryCrash Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 11import XCTest
22
33extension XCTestCase {
4- func givenStoredSentryCrashReport( resource: String ) throws {
4+
5+ private func jsonDataOfResource( resource: String ) throws -> Data {
56 let jsonPath = Bundle ( for: type ( of: self ) ) . path ( forResource: resource, ofType: " json " )
6- let jsonData = try Data ( contentsOf: URL ( fileURLWithPath: jsonPath ?? " " ) )
7+ return try Data ( contentsOf: URL ( fileURLWithPath: jsonPath ?? " " ) )
8+ }
9+
10+ func givenStoredSentryCrashReport( resource: String ) throws {
11+ let jsonData = try jsonDataOfResource ( resource: resource)
712 jsonData. withUnsafeBytes { ( bytes: UnsafeRawBufferPointer ) -> Void in
813 let pointer = bytes. bindMemory ( to: Int8 . self)
914 sentrycrashcrs_addUserReport ( pointer. baseAddress, Int32 ( jsonData. count) )
1015 }
1116 }
1217
1318 func getCrashReport( resource: String ) throws -> [ String : Any ] {
14- let jsonPath = Bundle ( for: type ( of: self ) ) . path ( forResource: resource, ofType: " json " )
15- let jsonData = try Data ( contentsOf: URL ( fileURLWithPath: jsonPath ?? " " ) )
19+ let jsonData = try jsonDataOfResource ( resource: resource)
1620 return try JSONSerialization . jsonObject ( with: jsonData, options: [ ] ) as! [ String : Any ]
1721 }
1822}
Original file line number Diff line number Diff line change @@ -3,15 +3,15 @@ import XCTest
33final class SentryCrashDoctorTests : XCTestCase {
44
55 func testBadAccess( ) throws {
6- let report = try getCrashReport ( resource: " crash-bad-access " )
6+ let report = try getCrashReport ( resource: " Resources/ crash-bad-access" )
77
88 let diagnose = SentryCrashDoctor ( ) . diagnoseCrash ( report)
99
1010 XCTAssertEqual ( " EXC_ARM_DA_ALIGN at 0x13fd4582e. " , diagnose)
1111 }
1212
1313 func testBadAccess_NoSubcode( ) throws {
14- let report = try getCrashReport ( resource: " crash-bad-access-no-subcode " )
14+ let report = try getCrashReport ( resource: " Resources/ crash-bad-access-no-subcode" )
1515
1616 let diagnose = SentryCrashDoctor ( ) . diagnoseCrash ( report)
1717
You can’t perform that action at this time.
0 commit comments