Skip to content

Commit

Permalink
Deleting dropped report after fetching it
Browse files Browse the repository at this point in the history
  • Loading branch information
ArielDemarco committed Nov 5, 2024
1 parent 4db5d6e commit 9a0adaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sources/EmbraceCrash/EmbraceCrashReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public final class EmbraceCrashReporter: NSObject, CrashReporter {
// Check if we drop crashes for a specific signal using the signalsBlockList
if let crashSignal = self.getCrashSignal(fromReport: report),
self.shouldDropCrashReport(withSignal: crashSignal) {
self.deleteCrashReport(id: id.intValue)
continue
}

Expand Down
14 changes: 13 additions & 1 deletion Tests/EmbraceCrashTests/EmbraceCrashReporterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class EmbraceCrashReporterTests: XCTestCase {
XCTAssertEqual(reports.count, 1)
// and report shouldn't be the one with the SIGTERM signal
XCTAssertEqual(reports[0].internalId, 1)
// and dropped report should have been deleted
self.thenShouldntExistReport(withName: "appId-report-0000000000000002.json")

expectation.fulfill()
}
Expand Down Expand Up @@ -203,7 +205,8 @@ class EmbraceCrashReporterTests: XCTestCase {
XCTAssertEqual(reports.count, 1)
// and report shouldn't be the one with the SIGABRT signal
XCTAssertEqual(reports[0].internalId, 2)

// and dropped report should have been deleted
self.thenShouldntExistReport(withName: "appId-report-0000000000000001.json")
expectation.fulfill()
}

Expand All @@ -224,6 +227,15 @@ private extension EmbraceCrashReporterTests {
try FileManager.default.copyItem(atPath: report, toPath: basePath + toFilePath)
}

func thenShouldntExistReport(withName name: String) {
do {
let basePath = try XCTUnwrap(crashReporter.basePath)
XCTAssertFalse(FileManager.default.fileExists(atPath: basePath + "/Reports/" + name))
} catch let ex {
XCTFail(ex.localizedDescription)
}
}

func givenCrashReporter() {
crashReporter = EmbraceCrashReporter(queue: MockQueue())
crashReporter.install(context: context, logger: logger)
Expand Down

0 comments on commit 9a0adaf

Please sign in to comment.