From daec044c3f33ed550eefd81e6309e9adcefad550 Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Thu, 12 Mar 2026 09:50:18 +0000 Subject: [PATCH] =?UTF-8?q?Replace=20`Task.sleep(for:)`=20with=20`Task.sle?= =?UTF-8?q?ep(nanoseconds:)`=20in=20`EventL=E2=80=A6=20(#3548)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …oopTest` ### Motivation * `Task.sleep(for:)` and the `Duration` literals (`.milliseconds`, `.seconds`) require iOS 16.0+, tvOS 16.0+, and watchOS 9.0+, so these calls cause build failures on simulator test destinations in CI. ### Modifications * Replaced all five `Task.sleep(for:)` calls in `EventLoopTest.swift` with the universally available `Task.sleep(nanoseconds:)`. ### Result * `EventLoopTest` compiles for iOS, tvOS, and watchOS simulator destinations. Verified locally with `xcodebuild build-for-testing`. --- Tests/NIOPosixTests/EventLoopTest.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/NIOPosixTests/EventLoopTest.swift b/Tests/NIOPosixTests/EventLoopTest.swift index 00c8f5f3d..b63ec4294 100644 --- a/Tests/NIOPosixTests/EventLoopTest.swift +++ b/Tests/NIOPosixTests/EventLoopTest.swift @@ -934,7 +934,7 @@ final class MultiThreadedEventLoopGroupTests { task.cancel(promise: promise2) } - try await Task.sleep(for: .milliseconds(100)) + try await Task.sleep(nanoseconds: 100_000_000) } } @@ -968,7 +968,7 @@ final class MultiThreadedEventLoopGroupTests { confirm() } } - try await Task.sleep(for: .milliseconds(100)) + try await Task.sleep(nanoseconds: 100_000_000) } let cancellationHandle = try #require(task) @@ -976,7 +976,7 @@ final class MultiThreadedEventLoopGroupTests { promise1.futureResult.whenSuccess { confirmation() } promise2.futureResult.whenSuccess { confirmation() } cancellationHandle.cancel(promise: promise2) - try await Task.sleep(for: .seconds(1)) + try await Task.sleep(nanoseconds: 1_000_000_000) } } @@ -1013,7 +1013,7 @@ final class MultiThreadedEventLoopGroupTests { } // Allow 0.5 seconds for promises to incorrectly fulfill - try await Task.sleep(for: .milliseconds(500)) + try await Task.sleep(nanoseconds: 500_000_000) } // Phase 2 — now allow completion and verify they DO complete @@ -1029,7 +1029,7 @@ final class MultiThreadedEventLoopGroupTests { } // Allow 0.5 seconds for promises to correctly fulfill - try await Task.sleep(for: .milliseconds(500)) + try await Task.sleep(nanoseconds: 500_000_000) } }