Skip to content

Commit 15c8cd5

Browse files
authored
ref: Replace hardcoded launch arguments with enums to avoid typos or values changed (#5728)
1 parent 7273bf4 commit 15c8cd5

File tree

6 files changed

+62
-46
lines changed

6 files changed

+62
-46
lines changed

Samples/SentrySampleShared/SentrySampleShared/SentrySDKWrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ extension SentrySDKWrapper {
286286
}
287287

288288
func configureFeedback(config: SentryUserFeedbackConfiguration) {
289-
guard !args.contains("--io.sentry.feedback.all-defaults") else {
289+
guard !args.contains(SentrySDKOverrides.Feedback.allDefaults.rawValue) else {
290290
config.configureWidget = { widget in
291291
widget.layoutUIOffset = self.layoutOffset
292292
}

Samples/iOS-Swift/iOS-Swift-UITests/BaseUITest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BaseUITest: XCTestCase {
1515
XCUIDevice.shared.orientation = .portrait
1616
app.launchEnvironment["--io.sentry.scope.sdk-environment"] = "ui-tests"
1717
app.launchArguments.append(contentsOf: [
18-
"--io.sentry.wipe-data"
18+
SentrySDKOverrides.Special.wipeDataOnLaunch.rawValue
1919
])
2020
if automaticallyLaunchAndTerminateApp {
2121
launchApp()

Samples/iOS-Swift/iOS-Swift-UITests/ProfilingUITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ extension ProfilingUITests {
171171
case .continuous:
172172
app.launchArguments.append(SentrySDKOverrides.Profiling.disableUIProfiling.rawValue)
173173
case .trace:
174-
app.launchArguments.append("--io.sentry.disable-ui-profiling")
174+
app.launchArguments.append(SentrySDKOverrides.Profiling.disableUIProfiling.rawValue)
175175
app.launchEnvironment[SentrySDKOverrides.Profiling.sampleRate.rawValue] = "1"
176176
}
177177

Samples/iOS-Swift/iOS-Swift-UITests/UserFeedbackUITests.swift

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//swiftlint:disable file_length
22

3+
import SentrySampleShared
34
import XCTest
45

56
class UserFeedbackUITests: BaseUITest {
@@ -15,14 +16,14 @@ class UserFeedbackUITests: BaseUITest {
1516
super.setUp()
1617

1718
app.launchArguments.append(contentsOf: [
18-
"--io.sentry.feedback.no-animations",
19-
"--io.sentry.wipe-data",
19+
SentrySDKOverrides.Feedback.noAnimations.rawValue,
20+
SentrySDKOverrides.Special.wipeDataOnLaunch.rawValue,
2021

2122
// since the goal of these tests is only to exercise the UI of the widget and form, disable other SDK features to avoid any confounding factors that might fail or crash a test case
22-
"--io.sentry.disable-everything",
23+
SentrySDKOverrides.Special.disableEverything.rawValue,
2324

2425
// write base64-encoded data into the envelope file for attachments instead of raw bytes, specifically for images. this way the entire envelope contents can be more easily passed as a string through the text field in the app to this process for validation.
25-
"--io.sentry.other.base64-attachment-data"
26+
SentrySDKOverrides.Other.base64AttachmentData.rawValue
2627
])
2728
continueAfterFailure = true
2829
}
@@ -32,7 +33,7 @@ extension UserFeedbackUITests {
3233
// MARK: Tests ensuring correct appearance
3334

3435
func testUIElementsWithDefaults() {
35-
launchApp(args: ["--io.sentry.feedback.all-defaults"])
36+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue])
3637
// widget button text
3738
XCTAssert(app.otherElements["Report a Bug"].exists)
3839

@@ -88,10 +89,10 @@ extension UserFeedbackUITests {
8889

8990
func testPrefilledUserInformation() throws {
9091
launchApp(args: [
91-
"--io.sentry.feedback.all-defaults"
92+
SentrySDKOverrides.Feedback.allDefaults.rawValue
9293
], env: [
93-
"--io.sentry.scope.user.name": "ui test user",
94-
"--io.sentry.scope.user.email": "ui-testing@sentry.io"
94+
SentrySDKOverrides.Other.userFullName.rawValue: "ui test user",
95+
SentrySDKOverrides.Other.userEmail.rawValue: "ui-testing@sentry.io"
9596
])
9697

9798
widgetButton.tap()
@@ -101,10 +102,10 @@ extension UserFeedbackUITests {
101102

102103
func testNoPrefilledUserInformation() throws {
103104
launchApp(args: [
104-
"--io.sentry.feedback.dont-use-sentry-user"
105+
SentrySDKOverrides.Feedback.noUserInjection.rawValue
105106
], env: [
106-
"--io.sentry.scope.user.name": "ui test user",
107-
"--io.sentry.scope.user.email": "ui-testing@sentry.io"
107+
SentrySDKOverrides.Other.userFullName.rawValue: "ui test user",
108+
SentrySDKOverrides.Other.userEmail.rawValue: "ui-testing@sentry.io"
108109
])
109110

110111
widgetButton.tap()
@@ -117,7 +118,9 @@ extension UserFeedbackUITests {
117118
// MARK: Tests validating happy path / successful submission
118119

119120
func testSubmitFullyFilledCustomForm() throws {
120-
launchApp(args: ["--io.sentry.feedback.dont-use-sentry-user"])
121+
launchApp(args: [
122+
SentrySDKOverrides.Feedback.noUserInjection.rawValue
123+
])
121124

122125
try retrieveAppUnderTestApplicationSupportDirectory()
123126
try assertHookMarkersNotExist()
@@ -155,9 +158,9 @@ extension UserFeedbackUITests {
155158
let testName = "Andrew"
156159
let testContactEmail = "andrew.mcknight@sentry.io"
157160

158-
launchApp(args: ["--io.sentry.feedback.all-defaults"], env: [
159-
"--io.sentry.scope.user.name": testName,
160-
"--io.sentry.scope.user.email": testContactEmail
161+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue], env: [
162+
SentrySDKOverrides.Other.userFullName.rawValue: testName,
163+
SentrySDKOverrides.Other.userEmail.rawValue: testContactEmail
161164
])
162165

163166
try retrieveAppUnderTestApplicationSupportDirectory()
@@ -202,8 +205,8 @@ extension UserFeedbackUITests {
202205

203206
func testSubmitCustomButton() throws {
204207
launchApp(args: [
205-
"--io.sentry.feedback.use-custom-feedback-button",
206-
"--io.sentry.feedback.dont-use-sentry-user"
208+
SentrySDKOverrides.Feedback.useCustomFeedbackButton.rawValue,
209+
SentrySDKOverrides.Feedback.noUserInjection.rawValue
207210
])
208211

209212
try retrieveAppUnderTestApplicationSupportDirectory()
@@ -243,9 +246,9 @@ extension UserFeedbackUITests {
243246
let testName = "Andrew"
244247
let testContactEmail = "andrew.mcknight@sentry.io"
245248

246-
launchApp(args: ["--io.sentry.feedback.all-defaults"], env: [
247-
"--io.sentry.scope.user.name": testName,
248-
"--io.sentry.scope.user.email": testContactEmail
249+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue], env: [
250+
SentrySDKOverrides.Other.userFullName.rawValue: testName,
251+
SentrySDKOverrides.Other.userEmail.rawValue: testContactEmail
249252
])
250253

251254
try retrieveAppUnderTestApplicationSupportDirectory()
@@ -272,9 +275,9 @@ extension UserFeedbackUITests {
272275
let testName = "Andrew"
273276
let testContactEmail = "andrew.mcknight@sentry.io"
274277

275-
launchApp(args: ["--io.sentry.feedback.all-defaults"], env: [
276-
"--io.sentry.scope.user.name": testName,
277-
"--io.sentry.scope.user.email": testContactEmail
278+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue], env: [
279+
SentrySDKOverrides.Other.userFullName.rawValue: testName,
280+
SentrySDKOverrides.Other.userEmail.rawValue: testContactEmail
278281
])
279282

280283
try retrieveAppUnderTestApplicationSupportDirectory()
@@ -309,9 +312,9 @@ extension UserFeedbackUITests {
309312
let testName = "Andrew"
310313
let testContactEmail = "andrew.mcknight@sentry.io"
311314

312-
launchApp(args: ["--io.sentry.feedback.all-defaults"], env: [
313-
"--io.sentry.scope.user.name": testName,
314-
"--io.sentry.scope.user.email": testContactEmail
315+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue], env: [
316+
SentrySDKOverrides.Other.userFullName.rawValue: testName,
317+
SentrySDKOverrides.Other.userEmail.rawValue: testContactEmail
315318
])
316319

317320
try retrieveAppUnderTestApplicationSupportDirectory()
@@ -341,7 +344,9 @@ extension UserFeedbackUITests {
341344
// MARK: Tests validating screenshot functionality
342345

343346
func testAddingScreenshots() throws {
344-
launchApp(args: ["--io.sentry.feedback.inject-screenshot"])
347+
launchApp(args: [
348+
SentrySDKOverrides.Feedback.injectScreenshot.rawValue
349+
])
345350
XCTAssert(removeScreenshotButton.isHittable)
346351

347352
let testMessage = "UITest user feedback"
@@ -353,7 +358,9 @@ extension UserFeedbackUITests {
353358
}
354359

355360
func testAddingAndRemovingScreenshots() throws {
356-
launchApp(args: ["--io.sentry.feedback.inject-screenshot"])
361+
launchApp(args: [
362+
SentrySDKOverrides.Feedback.injectScreenshot.rawValue
363+
])
357364
XCTAssert(removeScreenshotButton.isHittable)
358365
removeScreenshotButton.tap()
359366
XCTAssertFalse(removeScreenshotButton.isHittable)
@@ -369,7 +376,7 @@ extension UserFeedbackUITests {
369376
// MARK: Tests validating error cases
370377

371378
func testSubmitWithNoFieldsFilledDefault() throws {
372-
launchApp(args: ["--io.sentry.feedback.all-defaults"])
379+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue])
373380

374381
try retrieveAppUnderTestApplicationSupportDirectory()
375382
try assertHookMarkersNotExist()
@@ -389,7 +396,10 @@ extension UserFeedbackUITests {
389396
}
390397

391398
func testSubmitWithNoFieldsFilledEmailAndMessageRequired() throws {
392-
launchApp(args: ["--io.sentry.feedback.require-email", "--io.sentry.feedback.dont-use-sentry-user"])
399+
launchApp(args: [
400+
SentrySDKOverrides.Feedback.requireEmail.rawValue,
401+
SentrySDKOverrides.Feedback.noUserInjection.rawValue
402+
])
393403

394404
try retrieveAppUnderTestApplicationSupportDirectory()
395405
try assertHookMarkersNotExist()
@@ -414,9 +424,9 @@ extension UserFeedbackUITests {
414424

415425
func testSubmitWithNoFieldsFilledAllRequired() throws {
416426
launchApp(args: [
417-
"--io.sentry.feedback.require-email",
418-
"--io.sentry.feedback.require-name",
419-
"--io.sentry.feedback.dont-use-sentry-user"
427+
SentrySDKOverrides.Feedback.requireEmail.rawValue,
428+
SentrySDKOverrides.Feedback.requireName.rawValue,
429+
SentrySDKOverrides.Feedback.noUserInjection.rawValue
420430
])
421431

422432
try retrieveAppUnderTestApplicationSupportDirectory()
@@ -440,7 +450,7 @@ extension UserFeedbackUITests {
440450
}
441451

442452
func testSubmitOnlyWithOptionalFieldsFilled() throws {
443-
launchApp(args: ["--io.sentry.feedback.all-defaults"])
453+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue])
444454

445455
try retrieveAppUnderTestApplicationSupportDirectory()
446456
try assertHookMarkersNotExist()
@@ -462,9 +472,9 @@ extension UserFeedbackUITests {
462472
let testName = "Andrew"
463473
let testContactEmail = "andrew.mcknight@sentry.io"
464474

465-
launchApp(args: ["--io.sentry.feedback.all-defaults"], env: [
466-
"--io.sentry.scope.user.name": testName,
467-
"--io.sentry.scope.user.email": testContactEmail
475+
launchApp(args: [SentrySDKOverrides.Feedback.allDefaults.rawValue], env: [
476+
SentrySDKOverrides.Other.userFullName.rawValue: testName,
477+
SentrySDKOverrides.Other.userEmail.rawValue: testContactEmail
468478
])
469479

470480
try retrieveAppUnderTestApplicationSupportDirectory()
@@ -492,7 +502,9 @@ extension UserFeedbackUITests {
492502
// MARK: Alternative widget control
493503

494504
func testFormShowsAndDismissesProperlyWithCustomButton() {
495-
launchApp(args: ["--io.sentry.feedback.use-custom-feedback-button"])
505+
launchApp(args: [
506+
SentrySDKOverrides.Feedback.useCustomFeedbackButton.rawValue
507+
])
496508

497509
customButton.tap()
498510
cancelButton.tap()
@@ -502,7 +514,9 @@ extension UserFeedbackUITests {
502514
}
503515

504516
func testNoAutomaticallyInjectedWidgetWithCustomButton() {
505-
launchApp(args: ["--io.sentry.feedback.use-custom-feedback-button"])
517+
launchApp(args: [
518+
SentrySDKOverrides.Feedback.useCustomFeedbackButton.rawValue
519+
])
506520

507521
XCTAssertFalse(widgetButton.isHittable)
508522
XCTAssert(customButton.isHittable)
@@ -516,7 +530,9 @@ extension UserFeedbackUITests {
516530
}
517531

518532
func testManuallyDisplayingWidget() {
519-
launchApp(args: ["--io.sentry.feedback.no-auto-inject-widget"])
533+
launchApp(args: [
534+
SentrySDKOverrides.Feedback.disableAutoInject.rawValue
535+
])
520536
XCTAssertFalse(widgetButton.isHittable)
521537
extrasAreaTabBarButton.tap()
522538
app.buttons["io.sentry.ui-test.button.show-widget"].tap()

Samples/iOS-Swift/iOS-Swift/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1818
print("[iOS-Swift] [debug] launch arguments: \(args)")
1919
print("[iOS-Swift] [debug] launch environment: \(env)")
2020

21-
if args.contains("--io.sentry.wipe-data") {
21+
if args.contains(SentrySDKOverrides.Special.wipeDataOnLaunch.rawValue) {
2222
removeAppData()
2323
}
2424

Samples/macOS-Swift/macOS-Swift-UITests/MacOSSwiftUITests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ private extension MacOSSwiftUITests {
2626
let app = XCUIApplication(bundleIdentifier: appBundleID)
2727

2828
if wipeData {
29-
app.launchArguments.append("--io.sentry.wipe-data")
29+
app.launchArguments.append(SentrySDKOverrides.Special.wipeDataOnLaunch.rawValue)
3030
}
3131

3232
try launchAndConfigureSubsequentLaunches(app: app, shouldProfileThisLaunch: false, shouldProfileNextLaunch: shouldProfileLaunches, shouldBeSandboxed: isSandboxed)
3333
app.terminate()
3434

3535
if wipeData {
36-
app.launchArguments.removeAll { $0 == "--io.sentry.wipe-data" }
36+
app.launchArguments.removeAll { $0 == SentrySDKOverrides.Special.wipeDataOnLaunch.rawValue }
3737
}
3838

3939
// second launch to profile a launch if configured

0 commit comments

Comments
 (0)