Skip to content

test: Async safe log write to console #5094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
62D6B2A72CCA354B004DDBF1 /* SentryUncaughtNSExceptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62D6B2A62CCA354B004DDBF1 /* SentryUncaughtNSExceptionsTests.swift */; };
62E081A929ED4260000F69FC /* SentryBreadcrumbDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 62E081A829ED4260000F69FC /* SentryBreadcrumbDelegate.h */; };
62E081AB29ED4322000F69FC /* SentryBreadcrumbTestDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E081AA29ED4322000F69FC /* SentryBreadcrumbTestDelegate.swift */; };
62E2119A2DAE99FC007D7262 /* SentryAsyncSafeLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 62E211992DAE99FC007D7262 /* SentryAsyncSafeLog.m */; };
62E300942D5202890037AA3F /* SentryExceptionCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E300932D5202830037AA3F /* SentryExceptionCodable.swift */; };
62EF86A12C626D39004E058B /* SentryANRTrackerV2Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621AE74E2C626CF70012E730 /* SentryANRTrackerV2Tests.swift */; };
62F05D2B2C0DB1F100916E3F /* SentryLogTestHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 62F05D2A2C0DB1F100916E3F /* SentryLogTestHelper.m */; };
Expand Down Expand Up @@ -1232,6 +1233,7 @@
62D6B2A62CCA354B004DDBF1 /* SentryUncaughtNSExceptionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUncaughtNSExceptionsTests.swift; sourceTree = "<group>"; };
62E081A829ED4260000F69FC /* SentryBreadcrumbDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryBreadcrumbDelegate.h; path = include/SentryBreadcrumbDelegate.h; sourceTree = "<group>"; };
62E081AA29ED4322000F69FC /* SentryBreadcrumbTestDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBreadcrumbTestDelegate.swift; sourceTree = "<group>"; };
62E211992DAE99FC007D7262 /* SentryAsyncSafeLog.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryAsyncSafeLog.m; sourceTree = "<group>"; };
62E300932D5202830037AA3F /* SentryExceptionCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExceptionCodable.swift; sourceTree = "<group>"; };
62F05D292C0DB1C800916E3F /* SentryLogTestHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryLogTestHelper.h; sourceTree = "<group>"; };
62F05D2A2C0DB1F100916E3F /* SentryLogTestHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryLogTestHelper.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3318,6 +3320,7 @@
62375FB82B47F9F000CC55F1 /* SentryDependencyContainerTests.swift */,
62CFD9A82C99741100834E1B /* SentryInvalidJSONStringTests.swift */,
628B89012D841D7F004B6F2A /* SentryDateUtilsTests.swift */,
62E211992DAE99FC007D7262 /* SentryAsyncSafeLog.m */,
);
path = Helper;
sourceTree = "<group>";
Expand Down Expand Up @@ -5516,6 +5519,7 @@
D42E48572D48DF1600D251BC /* SentryBuildAppStartSpansTests.swift in Sources */,
D884A20527C80F6300074664 /* SentryCoreDataTrackerTest.swift in Sources */,
8E70B10125CB8695002B3155 /* SentrySpanIdTests.swift in Sources */,
62E2119A2DAE99FC007D7262 /* SentryAsyncSafeLog.m in Sources */,
84EB21962BF01CEA00EDDA28 /* SentryCrashInstallationTests.swift in Sources */,
7BFE7A0A27A1B6B000D2B66E /* SentryWatchdogTerminationsIntegrationTests.swift in Sources */,
D8292D7D2A39A027009872F7 /* UrlSanitizedTests.swift in Sources */,
Expand Down
26 changes: 26 additions & 0 deletions Tests/SentryTests/Helper/SentryAsyncSafeLog.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#import "SentryAsyncSafeLog.h"
#import <XCTest/XCTest.h>

@interface SentryAsyncSafeLog : XCTestCase

@end

@implementation SentryAsyncSafeLog

#if SENTRY_ASYNC_SAFE_LOG_ALSO_WRITE_TO_CONSOLE

/*
* This test only runs when SENTRY_ASYNC_SAFE_LOG_ALSO_WRITE_TO_CONSOLE is set to 1. We must only
* set SENTRY_ASYNC_SAFE_LOG_ALSO_WRITE_TO_CONSOLE in SentryAsyncSafeLog.h to 1 for debugging
* purposes but we MUST never commit this change to the main branch.
*/
- (void)testAsyncSafeLogDoesNotWriteToConsole
{
XCTFail(@"SENTRY_ASYNC_SAFE_LOG_ALSO_WRITE_TO_CONSOLE must not be set to 1, because it "
@"compromises async safety. You must only use it for debugging purposes. See "
@"SentryAsyncSafeLog.h for more context.");
}

#endif // SENTRY_ASYNC_SAFE_LOG_ALSO_WRITE_TO_CONSOLE

@end
Loading