Skip to content

Commit 3fc7f59

Browse files
authored
Merge pull request #629 from compnerd/android-time
Testing: use `clock_gettime` on Android
2 parents 6ba948a + 80e1e94 commit 3fc7f59

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/Testing/Events/Clock.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ extension Test {
4141
/// The wall-clock time corresponding to this instant.
4242
fileprivate(set) var wall: TimeValue = {
4343
var wall = timespec()
44+
#if os(Android)
45+
// Android headers recommend `clock_gettime` over `timespec_get` which
46+
// is available with API Level 29+ for `TIME_UTC`.
47+
clock_gettime(CLOCK_REALTIME, &wall)
48+
#else
4449
timespec_get(&wall, TIME_UTC)
50+
#endif
4551
return TimeValue(wall)
4652
}()
4753
#endif

0 commit comments

Comments
 (0)