Skip to content

Commit 3f75d62

Browse files
chore: mirror SentryCrash install path configuration
The integration appends 'KSCrash/<bundleIdentifier>' to the SDK's cacheDirectoryPath before passing it to the installer. The existing 'shouldCallInstallOnce' test was asserting installPath == cacheDirectoryPath directly, which became stale once the path was modified. Fix the stale assertion and add a dedicated test that mirrors the same URL construction, asserting the installer receives the expected subdirectory path.
1 parent 2e577f2 commit 3f75d62

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

Sources/Swift/Integrations/KSCrash/SentryKSCrash+Integration.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ extension SentryKSCrash {
3232
self.options = options
3333
super.init()
3434

35+
// To match KSCrash & SentryCrash, we need to add 'KSCrash/<bundlename>' to the cacheDirectoryPath
36+
let installPath = URL(fileURLWithPath: options.cacheDirectoryPath)
37+
.appendingPathComponent("KSCrash")
38+
.appendingPathComponent(Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String ?? "Unknown")
39+
.absoluteURL
40+
3541
do {
3642
try dependencies.kscrashInstaller.install(
37-
installPath: options.cacheDirectoryPath,
43+
installPath: installPath.path,
3844
monitors: productionSafeMonitors,
3945
enableSwapCxaThrow: options.experimental.enableUnhandledCPPExceptionsV2
4046
)

Tests/SentryTests/Integrations/KSCrash/SentryKSCrash+IntegrationTests.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,24 @@ class SentryKSCrashIntegrationTests: XCTestCase {
2727

2828
XCTAssertNotNil(sut)
2929
XCTAssertEqual(installer.installCalls.count, 1)
30-
XCTAssertEqual(installer.installCalls[0].installPath, options.cacheDirectoryPath)
3130
XCTAssertEqual(installer.installCalls[0].monitors, SentryKSCrash.productionSafeMonitors)
3231
}
3332

33+
func testInstall_whenCrashHandlerEnabled_shouldAppendKSCrashBundleSubdirectory() {
34+
let installer = MockKSCrashInstaller()
35+
let deps = MockKSCrashDependencies(installer: installer)
36+
let options = makeOptions()
37+
let bundleID = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String ?? "Unknown"
38+
let expectedPath = URL(fileURLWithPath: options.cacheDirectoryPath)
39+
.appendingPathComponent("KSCrash")
40+
.appendingPathComponent(bundleID)
41+
.path
42+
43+
_ = SentryKSCrash.Integration(with: options, dependencies: deps)
44+
45+
XCTAssertEqual(installer.installCalls[0].installPath, expectedPath)
46+
}
47+
3448
func testInstall_whenCrashedLastLaunch_shouldSetFatalDetected() {
3549
let installer = MockKSCrashInstaller()
3650
installer.crashedLastLaunch = true

0 commit comments

Comments
 (0)