From 0d2f72172f01123dad278ccf579b3feeaaa0cfda Mon Sep 17 00:00:00 2001 From: Si Beaumont Date: Tue, 30 Jul 2024 12:18:12 +0100 Subject: [PATCH] Fix test compilation on non-macOS Darwin platforms (#2817) ### Motivation Some tests were making use of `Task.sleep(for:)` which isn't present on older platforms. ``` /workspace/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift:505:32: error: 'sleep(for:tolerance:clock:)' is only available in tvOS 16.0 or newer try await Task.sleep(for: .milliseconds(1)) ``` ### Modifications Update tests to use `Task.sleep(nanoseconds:)` via `TimeAmount.nanoseconds` instead, which is available on those platforms. ### Result Can build tests on older platforms. --- Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift b/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift index 28077adf1..2da6381e0 100644 --- a/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift +++ b/Tests/NIOEmbeddedTests/AsyncTestingEventLoopTests.swift @@ -502,7 +502,7 @@ final class NIOAsyncTestingEventLoopTests: XCTestCase { try await withThrowingTaskGroup(of: Void.self) { group in group.addTask { - try await Task.sleep(for: .milliseconds(1)) + try await Task.sleep(nanoseconds: 1_000_000) await eventLoop.shutdownGracefully() } group.addTask {