Skip to content

Commit

Permalink
Add missing availability guards in tests (#2596)
Browse files Browse the repository at this point in the history
# Motivation
We were missing a few availability guards in our tests which causes compile time errors when building for older Darwin SDKs.

# Modification
This PR adds the missing availability guards.
  • Loading branch information
FranzBusch committed Nov 24, 2023
1 parent 703ee91 commit 8024902
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@testable import NIOCore
import XCTest

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class AsyncChannelInboundStreamTests: XCTestCase {
func testTestingStream() async throws {
let (stream, source) = NIOAsyncChannelInboundStream<Int>.makeTestingStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@testable import NIOCore
import XCTest

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class AsyncChannelOutboundWriterTests: XCTestCase {
func testTestingWriter() async throws {
let (writer, sink) = NIOAsyncChannelOutboundWriter<Int>.makeTestingWriter()
Expand Down
2 changes: 2 additions & 0 deletions Tests/NIOCoreTests/AsyncChannel/AsyncChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ private final class CloseSuppressor: ChannelOutboundHandler, RemovableChannelHan
}
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension NIOAsyncTestingChannel {
fileprivate func closeIgnoringSuppression() async throws {
try await self.pipeline.context(handlerType: CloseSuppressor.self).flatMap {
Expand Down Expand Up @@ -455,6 +456,7 @@ private enum TestError: Error {
case bang
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension Array {
fileprivate init<AS: AsyncSequence>(_ sequence: AS) async throws where AS.Element == Self.Element {
self = []
Expand Down
3 changes: 3 additions & 0 deletions Tests/NIOCoreTests/AsyncSequences/NIOAsyncSequenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import NIOCore
import XCTest

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class MockNIOElementStreamBackPressureStrategy: NIOAsyncSequenceProducerBackPressureStrategy, @unchecked Sendable {
enum Event {
case didYield
Expand Down Expand Up @@ -48,6 +49,7 @@ final class MockNIOElementStreamBackPressureStrategy: NIOAsyncSequenceProducerBa
}
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class MockNIOBackPressuredStreamSourceDelegate: NIOAsyncSequenceProducerDelegate, @unchecked Sendable {
enum Event {
case produceMore
Expand Down Expand Up @@ -673,6 +675,7 @@ fileprivate func XCTAssertEqualWithoutAutoclosure<T>(
XCTAssertEqual(expression1, expression2, message(), file: file, line: line)
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension AsyncSequence {
/// Collect all elements in the sequence into an array.
fileprivate func collect() async rethrows -> [Element] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ fileprivate func XCTAssertEqualWithoutAutoclosure<T>(
XCTAssertEqual(expression1, expression2, message(), file: file, line: line)
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension AsyncSequence {
/// Collect all elements in the sequence into an array.
fileprivate func collect() async rethrows -> [Element] {
Expand Down
2 changes: 2 additions & 0 deletions Tests/NIOPosixTests/AsyncChannelBootstrapTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private final class AddressedEnvelopingHandler: ChannelDuplexHandler {
}
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
final class AsyncChannelBootstrapTests: XCTestCase {
enum NegotiationResult {
case string(NIOAsyncChannel<String, String>)
Expand Down Expand Up @@ -1358,6 +1359,7 @@ final class AsyncChannelBootstrapTests: XCTestCase {
}
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension AsyncStream {
fileprivate static func makeStream(
of elementType: Element.Type = Element.self,
Expand Down
1 change: 1 addition & 0 deletions Tests/NIOPosixTests/SerialExecutorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ final class SerialExecutorTests: XCTestCase {
try await self._testBasicExecutorFitsOnEventLoop(loop1: loops[0], loop2: loops[1])
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
func testBasicExecutorFitsOnEventLoop_AsyncTestingEventLoop() async throws {
let loop1 = NIOAsyncTestingEventLoop()
let loop2 = NIOAsyncTestingEventLoop()
Expand Down

0 comments on commit 8024902

Please sign in to comment.