Skip to content

Commit b6d6159

Browse files
committed
chore: Fix watchOS tests and add them to nightly job
1 parent 3fcdded commit b6d6159

21 files changed

+54
-18
lines changed

.github/workflows/nightly-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ jobs:
4545
platform: "iOS"
4646
device: "iPad Pro 13-inch (M5)"
4747

48+
- name: watchOS 26 Sentry
49+
runs-on: tahoe
50+
xcode: "26.2"
51+
test-destination-os: "26.4"
52+
platform: "watchOS"
53+
device: "Apple Watch Ultra 3 (49mm)"
54+
timeout: 30
55+
4856
- name: visionOS 2.5 Sentry
4957
runs-on: sequoia
5058
xcode: "26.0.1"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ lint-staged:
715715
./scripts/check-clang-format.py -r Sources Tests
716716
ruby ./scripts/check-objc-id-usage.rb -r Sources/Sentry
717717
@if [ -n "$(STAGED_SWIFT_FILES)" ]; then \
718-
swiftlint --strict --quiet --config .swiftlint.yml $(STAGED_SWIFT_FILES); \
718+
swiftlint --strict --quiet $(STAGED_SWIFT_FILES); \
719719
fi
720720
dprint check "**/*.{md,json,yaml,yml}"
721721

SentryTestUtils/Sources/TestNSNotificationCenterWrapper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Foundation
22
@_spi(Private) import Sentry
33

4-
#if canImport(UIKit)
4+
#if (os(iOS) || os(tvOS) || os(visionOS))
55
import UIKit
66
public typealias CrossPlatformApplication = UIApplication
7-
#else
7+
#elseif os(macOS)
88
import AppKit
99
public typealias CrossPlatformApplication = NSApplication
1010
#endif

Sources/Sentry/SentryDevice.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@
173173
return @"Catalyst";
174174
#elif SENTRY_HAS_UIKIT
175175
return [UIDevice currentDevice].systemName;
176+
#elif TARGET_OS_WATCH
177+
return @"watchOS";
176178
#else
177179
return @"macOS";
178180
#endif // SENTRY_HAS_UIKIT

Tests/SentryTests/Helper/SentryDeviceTests.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,19 @@ - (void)testCPUArchitecture
9999
- (void)testOSVersion
100100
{
101101
NSString *osVersion = sentry_getOSVersion();
102+
#if TARGET_OS_WATCH
103+
XCTAssertEqual(osVersion.length, 0U);
104+
#else
102105
XCTAssertNotEqual(osVersion.length, 0U);
106+
#endif
107+
103108
#if TARGET_OS_OSX
104109
SENTRY_ASSERT_PREFIX(osVersion, @"10.", @"11.", @"12.", @"13.", @"14.", @"15.", @"26.");
105110
#elif TARGET_OS_IOS || TARGET_OS_MACCATALYST || TARGET_OS_TV
106111
SENTRY_ASSERT_PREFIX(osVersion, @"9.", @"10.", @"11.", @"12.", @"13.", @"14.", @"15.", @"16.",
107112
@"17.", @"18.", @"26.");
108113
#elif TARGET_OS_WATCH
109-
// TODO: create a watch UI test target to test this branch
110-
SENTRY_ASSERT_PREFIX(osVersion, @"2.", @"3.", @"4.", @"5.", @"6.", @"7.", @"8.", @"9.", @"26.");
114+
XCTAssertEqualObjects(osVersion, @"");
111115
#elif TARGET_OS_VISION
112116
SENTRY_ASSERT_PREFIX(osVersion, @"1.", @"2.", @"26.");
113117
#else
@@ -137,7 +141,6 @@ - (void)testOSName
137141
// cannot.
138142
SENTRY_ASSERT_EQUAL(osName, @"tvOS");
139143
#elif TARGET_OS_WATCH
140-
// TODO: create a watch UI test target to test this branch
141144
SENTRY_ASSERT_EQUAL(osName, @"watchOS");
142145
#elif TARGET_OS_VISION
143146
SENTRY_ASSERT_EQUAL(osName, @"visionOS");

Tests/SentryTests/Integrations/MetricKit/SentryMXManagerTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import MetricKit
21
@_spi(Private) @testable import Sentry
32
import SentryTestUtils
43
import XCTest

Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerIntegrationTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class SentryNetworkTrackerIntegrationTests: XCTestCase {
109109
* Reproduces https://github.com/getsentry/sentry-cocoa/issues/1288
110110
*/
111111
func testCustomURLProtocol_BlocksAllRequests() throws {
112+
#if !os(watchOS)
112113
startSDK()
113114

114115
let expect = expectation(description: "Callback Expectation")
@@ -130,6 +131,9 @@ class SentryNetworkTrackerIntegrationTests: XCTestCase {
130131

131132
dataTask.resume()
132133
wait(for: [expect], timeout: 5)
134+
#else
135+
throw XCTSkip("Test is disabled for watchOS")
136+
#endif
133137
}
134138

135139
private func flaky_testWhenTaskCancelledOrSuspended_OnlyOneBreadcrumb() {

Tests/SentryTests/Integrations/Session/SentrySessionTrackerTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@_spi(Private) import SentryTestUtils
33
import XCTest
44

5+
#if !os(watchOS)
56
class SentrySessionTrackerTests: XCTestCase {
67

78
private static let dsnAsString = TestConstants.dsnAsString(username: "SentrySessionTrackerTests")
@@ -891,3 +892,4 @@ class SentrySessionTrackerTests: XCTestCase {
891892
)
892893
}
893894
}
895+
#endif

Tests/SentryTests/Networking/TestSentryReachability.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(watchOS) && !(os(visionOS) && !canImport(UIKit))
1+
#if !(os(visionOS) && !canImport(UIKit))
22

33
@_spi(Private) @testable import Sentry
44
import SentryTestUtils
@@ -30,4 +30,4 @@ import SentryTestUtils
3030
}
3131
}
3232

33-
#endif // !os(watchOS) && !(os(visionOS) && !canImport(UIKit))
33+
#endif // && !(os(visionOS) && !canImport(UIKit))

Tests/SentryTests/OptionsInSyncWithDocs/MdxOptionsParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
///
55
/// - Parameter content: The MDX file content to parse.
66
/// - Returns: A set of option names found in the content.
7-
@available(iOS 16.0, tvOS 16.0, macOS 13.0, macCatalyst 16.0, *)
7+
@available(iOS 16.0, tvOS 16.0, macOS 13.0, macCatalyst 16.0, watchOS 9.0, *)
88
func extractMdxOptionNames(from content: String) -> Set<String> {
99
// Pattern: <SdkOption name="optionName"> with single or double quotes
1010
let regex = /<SdkOption\s+name\s*=\s*["'](?<name>[^"']+)["']/

0 commit comments

Comments
 (0)