Skip to content

Commit 62b3d9e

Browse files
committed
Unit tests de-flaking
1 parent 2eee3c1 commit 62b3d9e

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Tests/OSCKitCoreTests/OSCTimeTag/OSCTimeTag Static Constructors Tests.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import Testing
1010
import Numerics
1111

1212
@Suite struct OSCTimeTag_StaticConstructors_Tests {
13+
#if os(macOS) || os(iOS)
14+
let tolerance: TimeInterval = 0.001
15+
#elseif os(tvOS) || os(watchOS)
16+
// allow more time variance for CI pipeline to de-flake
17+
let tolerance: TimeInterval = 0.01
18+
#endif
19+
1320
// MARK: - Static Constructors
1421

1522
@Test func timeTagImmediate() {
@@ -35,7 +42,7 @@ import Numerics
3542

3643
let valTI = try #require((val as? OSCTimeTag)?.timeInterval(since: primeEpoch))
3744
let nowTI = now.timeInterval(since: primeEpoch)
38-
#expect(valTI.isApproximatelyEqual(to: nowTI, absoluteTolerance: 0.001))
45+
#expect(valTI.isApproximatelyEqual(to: nowTI, absoluteTolerance: tolerance))
3946
}
4047

4148
@Test func oscValue_timeTagTimeIntervalSinceNow() throws {
@@ -45,7 +52,7 @@ import Numerics
4552
let valTI = try #require((val as? OSCTimeTag)?.timeInterval(since: primeEpoch))
4653
let nowTI = now.timeInterval(since: primeEpoch)
4754

48-
#expect(valTI.isApproximatelyEqual(to: nowTI, absoluteTolerance: 0.001))
55+
#expect(valTI.isApproximatelyEqual(to: nowTI, absoluteTolerance: tolerance))
4956
}
5057

5158
@Test func oscValue_timeTagTimeIntervalSince1900() {

Tests/OSCKitCoreTests/OSCTimeTag/OSCTimeTag Tests.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import OSCKitCore
99
import Testing
1010

1111
@Suite struct OSCTimeTag_Tests {
12+
#if os(macOS) || os(iOS)
13+
let tolerance: TimeInterval = 0.001
14+
#elseif os(tvOS) || os(watchOS)
15+
// allow more time variance for CI pipeline to de-flake
16+
let tolerance: TimeInterval = 0.01
17+
#endif
18+
1219
@Test func init_RawValue() {
1320
// ensure all raw values including 0 and 1 are allowed
1421
#expect(OSCTimeTag(0).rawValue == 0)
@@ -40,8 +47,7 @@ import Testing
4047
#expect(!tag.isImmediate)
4148
#expect(!tag.isFuture)
4249
#expect(tag.date < Date())
43-
#expect(tag.timeIntervalSinceNow().isApproximatelyEqual(to: -10.0, absoluteTolerance: 0.001))
44-
50+
#expect(tag.timeIntervalSinceNow().isApproximatelyEqual(to: -10.0, absoluteTolerance: tolerance))
4551
}
4652

4753
// MARK: - .init(timeIntervalSince1900:)
@@ -148,13 +154,13 @@ import Testing
148154
@Test func immediate_date() {
149155
let tag = OSCTimeTag.immediate()
150156
let date = Date()
151-
#expect(tag.date.timeIntervalSince(date).isApproximatelyEqual(to: 0.0, absoluteTolerance: 0.001))
157+
#expect(tag.date.timeIntervalSince(date).isApproximatelyEqual(to: 0.0, absoluteTolerance: tolerance))
152158
}
153159

154160
@Test func immediate_timeIntervalSinceNow() {
155161
let tag = OSCTimeTag.immediate()
156162
let captureSecondsFromNow = tag.timeIntervalSinceNow()
157-
#expect(captureSecondsFromNow.isApproximatelyEqual(to: 0.0, absoluteTolerance: 0.001))
163+
#expect(captureSecondsFromNow.isApproximatelyEqual(to: 0.0, absoluteTolerance: tolerance))
158164
}
159165

160166
// MARK: - .now()
@@ -182,14 +188,14 @@ import Testing
182188
@Test func now_date() {
183189
let tag = OSCTimeTag.now()
184190
let captureDate = tag.date
185-
#expect(Date().timeIntervalSince(captureDate).isApproximatelyEqual(to: 0.0, absoluteTolerance: 0.001))
191+
#expect(Date().timeIntervalSince(captureDate).isApproximatelyEqual(to: 0.0, absoluteTolerance: tolerance))
186192

187193
}
188194

189195
@Test func now_timeIntervalSinceNow() {
190196
let tag = OSCTimeTag.now()
191197
let captureSecondsFromNow = tag.timeIntervalSinceNow()
192-
#expect(captureSecondsFromNow.isApproximatelyEqual(to: 0.0, absoluteTolerance: 0.001))
198+
#expect(captureSecondsFromNow.isApproximatelyEqual(to: 0.0, absoluteTolerance: tolerance))
193199
}
194200
}
195201

0 commit comments

Comments
 (0)