Skip to content

Commit 317489d

Browse files
committed
Fix Tests
1 parent c2aecc1 commit 317489d

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

FlyingSocks/Sources/SocketPool+ePoll.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import CSystemLinux
3434

3535
public extension AsyncSocketPool where Self == SocketPool<ePoll> {
3636
static func ePoll(maxEvents limit: Int = 20) -> SocketPool<ePoll> {
37-
SocketPool(queue: ePoll(maxEvents: limit))
37+
SocketPool(queue: FlyingSocks.ePoll(maxEvents: limit))
3838
}
3939
}
4040

FlyingSocks/Sources/SocketPool.swift

+15
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ public func makeEventQueuePool(maxEvents limit: Int = 20) -> AsyncSocketPool {
6363
#endif
6464
}
6565

66+
#if compiler(>=5.7)
67+
public extension AsyncSocketPool where Self == SocketPool<Poll> {
68+
69+
static func make(maxEvents limit: Int = 20) -> SocketPool<some EventQueue> {
70+
#if canImport(Darwin)
71+
return .kQueue(maxEvents: limit)
72+
#elseif canImport(CSystemLinux)
73+
return .ePoll(maxEvents: limit)
74+
#else
75+
return .poll(interval: .seconds(0.01))
76+
#endif
77+
}
78+
}
79+
#endif
80+
6681
public final actor SocketPool<Queue: EventQueue>: AsyncSocketPool {
6782

6883
private(set) var queue: Queue

FlyingSocks/Tests/SocketPoolTests.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,20 @@ final class SocketPoolTests: XCTestCase {
3737
typealias Continuation = CancellingContinuation<Void, SocketError>
3838
typealias Waiting = SocketPool<MockEventQueue>.Waiting
3939

40-
#if canImport(Darwin)
40+
#if canImport(Darwin) && compiler(>=5.7)
4141
func testKqueuePool() {
42-
let pool = makeEventQueuePool()
42+
let pool = SocketPool.make(maxEvents: 5)
4343
XCTAssertTrue(type(of: pool) == SocketPool<kQueue>.self)
4444
}
4545
#endif
4646

47+
#if canImport(CSystemLinux) && compiler(>=5.7)
48+
func testEPollPool() {
49+
let pool = SocketPool.make(maxEvents: 5)
50+
XCTAssertTrue(type(of: pool) == SocketPool<ePoll>.self)
51+
}
52+
#endif
53+
4754
func testQueuePrepare() async throws {
4855
let pool = SocketPool.make()
4956

0 commit comments

Comments
 (0)