Skip to content

Commit

Permalink
Fix: testCorruptEnvelope Test (#4316)
Browse files Browse the repository at this point in the history
Fixing flakiness of the test
  • Loading branch information
brustolin authored and armcknight committed Sep 7, 2024
1 parent bec7914 commit f366f68
Show file tree
Hide file tree
Showing 11 changed files with 473 additions and 231 deletions.
2 changes: 1 addition & 1 deletion Samples/iOS-Swift/iOS-Swift-UITests/LaunchUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class LaunchUITests: BaseUITest {
XCTAssertEqual(app.state, .notRunning)

app.launch()
XCTAssertEqual(app.state, .runningForeground)
app.tabBars.firstMatch.waitForExistence("App did not open again")
XCTAssertEqual(app.state, .runningForeground)
}

func testCheckTotalFrames() {
Expand Down
58 changes: 54 additions & 4 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
84ACC4432A73CD0700932A18 /* ProfilingCPUWork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84ACC4422A73CD0700932A18 /* ProfilingCPUWork.swift */; };
84B527B928DD24BA00475E8D /* SentryDeviceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84B527B728DD24BA00475E8D /* SentryDeviceTests.mm */; };
84B527BD28DD25E400475E8D /* SentryDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84B527BC28DD25E400475E8D /* SentryDevice.mm */; };
84BA71E42C8BBBEC0045B828 /* DSNDisplayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BA71E32C8BBBEC0045B828 /* DSNDisplayViewController.swift */; };
84BA71EC2C8BC3B90045B828 /* SwiftMessages in Frameworks */ = {isa = PBXBuildFile; productRef = 84BA71EB2C8BC3B90045B828 /* SwiftMessages */; };
84BA71EF2C8BC3C40045B828 /* Anchorage in Frameworks */ = {isa = PBXBuildFile; productRef = 84BA71EE2C8BC3C40045B828 /* Anchorage */; };
84BA71F12C8BC55A0045B828 /* Toasts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84BA71F02C8BC55A0045B828 /* Toasts.swift */; };
84BE546F287503F100ACC735 /* SentrySDKPerformanceBenchmarkTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 84BE546E287503F100ACC735 /* SentrySDKPerformanceBenchmarkTests.m */; };
84BE547E287645B900ACC735 /* SentryProcessInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 84BE54792876451D00ACC735 /* SentryProcessInfo.m */; };
84FB812A284001B800F3A94A /* SentryBenchmarking.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84FB8129284001B800F3A94A /* SentryBenchmarking.mm */; };
Expand Down Expand Up @@ -312,6 +316,8 @@
84B527B728DD24BA00475E8D /* SentryDeviceTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SentryDeviceTests.mm; path = ../../../Tests/SentryTests/Helper/SentryDeviceTests.mm; sourceTree = "<group>"; };
84B527BB28DD25E400475E8D /* SentryDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryDevice.h; path = ../../../Sources/Sentry/include/SentryDevice.h; sourceTree = "<group>"; };
84B527BC28DD25E400475E8D /* SentryDevice.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SentryDevice.mm; path = ../../../Sources/Sentry/SentryDevice.mm; sourceTree = "<group>"; };
84BA71E32C8BBBEC0045B828 /* DSNDisplayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DSNDisplayViewController.swift; sourceTree = "<group>"; };
84BA71F02C8BC55A0045B828 /* Toasts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toasts.swift; sourceTree = "<group>"; };
84BE546E287503F100ACC735 /* SentrySDKPerformanceBenchmarkTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySDKPerformanceBenchmarkTests.m; sourceTree = "<group>"; };
84BE54782876451D00ACC735 /* SentryProcessInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProcessInfo.h; sourceTree = "<group>"; };
84BE54792876451D00ACC735 /* SentryProcessInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryProcessInfo.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -375,6 +381,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
84BA71EF2C8BC3C40045B828 /* Anchorage in Frameworks */,
84BA71EC2C8BC3B90045B828 /* SwiftMessages in Frameworks */,
630853532440C60F00DDE4CE /* Sentry.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -613,6 +621,8 @@
D8832B192AF4FE2000C522B0 /* SentryUIApplication.h */,
629EC8AC2B0B537400858855 /* TriggerAppHang.swift */,
D82915932C889F1800A6CDD4 /* SentryCocoaPrivate.h */,
84BA71E32C8BBBEC0045B828 /* DSNDisplayViewController.swift */,
84BA71F02C8BC55A0045B828 /* Toasts.swift */,
);
path = Tools;
sourceTree = "<group>";
Expand Down Expand Up @@ -655,6 +665,10 @@
D840D533273A07F600CDF142 /* PBXTargetDependency */,
);
name = "iOS-Swift";
packageProductDependencies = (
84BA71EB2C8BC3B90045B828 /* SwiftMessages */,
84BA71EE2C8BC3C40045B828 /* Anchorage */,
);
productName = "iOS-Swift";
productReference = 637AFDA6243B02760034958B /* iOS-Swift.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -798,6 +812,8 @@
);
mainGroup = 637AFD9D243B02760034958B;
packageReferences = (
84BA71EA2C8BC3B90045B828 /* XCRemoteSwiftPackageReference "SwiftMessages" */,
84BA71ED2C8BC3C40045B828 /* XCRemoteSwiftPackageReference "Anchorage" */,
);
productRefGroup = 637AFDA7243B02760034958B /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -938,6 +954,7 @@
637AFDAE243B02760034958B /* TransactionsViewController.swift in Sources */,
D8832B132AF4F7FE00C522B0 /* TopViewControllerInspector.swift in Sources */,
0AABE2EA28855FF80057ED69 /* PermissionsViewController.swift in Sources */,
84BA71E42C8BBBEC0045B828 /* DSNDisplayViewController.swift in Sources */,
7B5525B32938B5B5006A2932 /* DiskWriteException.swift in Sources */,
D8F3D062274EBD4800B56F8C /* SpanExtension.swift in Sources */,
637AFDAA243B02760034958B /* AppDelegate.swift in Sources */,
Expand All @@ -959,6 +976,7 @@
7B79000429028C7300A7F467 /* MetricKitManager.swift in Sources */,
D8D7BB4A2750067900044146 /* UIAssert.swift in Sources */,
D8F3D057274E574200B56F8C /* LoremIpsumViewController.swift in Sources */,
84BA71F12C8BC55A0045B828 /* Toasts.swift in Sources */,
629EC8AD2B0B537400858855 /* TriggerAppHang.swift in Sources */,
D8AE48C92C57DC2F0092A2A6 /* WebViewController.swift in Sources */,
D8DBDA78274D5FC400007380 /* SplitViewController.swift in Sources */,
Expand Down Expand Up @@ -1258,7 +1276,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
INFOPLIST_FILE = "iOS-Swift/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -1287,7 +1305,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
INFOPLIST_FILE = "iOS-Swift/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -1473,7 +1491,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
INFOPLIST_FILE = "iOS-Swift/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -1698,7 +1716,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 97JCY7859U;
INFOPLIST_FILE = "iOS-Swift/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -2112,6 +2130,38 @@
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
84BA71EA2C8BC3B90045B828 /* XCRemoteSwiftPackageReference "SwiftMessages" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SwiftKickMobile/SwiftMessages";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 10.0.0;
};
};
84BA71ED2C8BC3C40045B828 /* XCRemoteSwiftPackageReference "Anchorage" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Rightpoint/Anchorage";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.5.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
84BA71EB2C8BC3B90045B828 /* SwiftMessages */ = {
isa = XCSwiftPackageProductDependency;
package = 84BA71EA2C8BC3B90045B828 /* XCRemoteSwiftPackageReference "SwiftMessages" */;
productName = SwiftMessages;
};
84BA71EE2C8BC3C40045B828 /* Anchorage */ = {
isa = XCSwiftPackageProductDependency;
package = 84BA71ED2C8BC3C40045B828 /* XCRemoteSwiftPackageReference "Anchorage" */;
productName = Anchorage;
};
/* End XCSwiftPackageProductDependency section */

/* Begin XCVersionGroup section */
D845F35927BAD4CC00A4D7A2 /* SentryData.xcdatamodeld */ = {
isa = XCVersionGroup;
Expand Down
11 changes: 9 additions & 2 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let env = ProcessInfo.processInfo.environment

// For testing purposes, we want to be able to change the DSN and store it to disk. In a real app, you shouldn't need this behavior.
let dsn = env["--io.sentry.dsn"] ?? DSNStorage.shared.getDSN() ?? AppDelegate.defaultDSN
DSNStorage.shared.saveDSN(dsn: dsn)
var dsn: String?
do {
if let dsn = env["--io.sentry.dsn"] {
try DSNStorage.shared.saveDSN(dsn: dsn)
}
dsn = try DSNStorage.shared.getDSN() ?? AppDelegate.defaultDSN
} catch {
print("[iOS-Swift] Error encountered while reading stored DSN: \(error)")
}

SentrySDK.start(configureOptions: { options in
options.dsn = dsn
Expand Down
Loading

0 comments on commit f366f68

Please sign in to comment.