Use #fileID/#filePath instead of #file (#2306)
Motivation: #fileID introduced in Swift 5.3, so no longer need to use #file anywhere Modifications: Changed #file to #filePath or #fileID depending on the situation
This commit is contained in:
parent
06d4028cde
commit
af41276062
|
@ -106,7 +106,7 @@ extension ChannelOutboundInvoker {
|
|||
///
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||
public func register(file: StaticString = #file, line: UInt = #line) async throws {
|
||||
public func register(file: StaticString = #fileID, line: UInt = #line) async throws {
|
||||
try await self.register(file: file, line: line).get()
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - to: the `SocketAddress` to which we should bind the `Channel`.
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||
public func bind(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) async throws {
|
||||
public func bind(to address: SocketAddress, file: StaticString = #fileID, line: UInt = #line) async throws {
|
||||
try await self.bind(to: address, file: file, line: line).get()
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - to: the `SocketAddress` to which we should connect the `Channel`.
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||
public func connect(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) async throws {
|
||||
public func connect(to address: SocketAddress, file: StaticString = #fileID, line: UInt = #line) async throws {
|
||||
try await self.connect(to: address, file: file, line: line).get()
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - data: the data to write
|
||||
/// - returns: the future which will be notified once the `write` operation completes.
|
||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||
public func writeAndFlush(_ data: NIOAny, file: StaticString = #file, line: UInt = #line) async throws {
|
||||
public func writeAndFlush(_ data: NIOAny, file: StaticString = #fileID, line: UInt = #line) async throws {
|
||||
try await self.writeAndFlush(data, file: file, line: line).get()
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - mode: the `CloseMode` that is used
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||
public func close(mode: CloseMode = .all, file: StaticString = #file, line: UInt = #line) async throws {
|
||||
public func close(mode: CloseMode = .all, file: StaticString = #fileID, line: UInt = #line) async throws {
|
||||
try await self.close(mode: mode, file: file, line: line).get()
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - event: the event itself.
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
|
||||
public func triggerUserOutboundEvent(_ event: Any, file: StaticString = #file, line: UInt = #line) async throws {
|
||||
public func triggerUserOutboundEvent(_ event: Any, file: StaticString = #fileID, line: UInt = #line) async throws {
|
||||
try await self.triggerUserOutboundEvent(event, file: file, line: line).get()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ extension ChannelOutboundInvoker {
|
|||
/// Register on an `EventLoop` and so have all its IO handled.
|
||||
///
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
public func register(file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
public func register(file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
let promise = makePromise(file: file, line: line)
|
||||
register(promise: promise)
|
||||
return promise.futureResult
|
||||
|
@ -103,7 +103,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - parameters:
|
||||
/// - to: the `SocketAddress` to which we should bind the `Channel`.
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
public func bind(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
public func bind(to address: SocketAddress, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
let promise = makePromise(file: file, line: line)
|
||||
bind(to: address, promise: promise)
|
||||
return promise.futureResult
|
||||
|
@ -113,7 +113,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - parameters:
|
||||
/// - to: the `SocketAddress` to which we should connect the `Channel`.
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
public func connect(to address: SocketAddress, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
public func connect(to address: SocketAddress, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
let promise = makePromise(file: file, line: line)
|
||||
connect(to: address, promise: promise)
|
||||
return promise.futureResult
|
||||
|
@ -127,7 +127,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - parameters:
|
||||
/// - data: the data to write
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
public func write(_ data: NIOAny, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
public func write(_ data: NIOAny, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
let promise = makePromise(file: file, line: line)
|
||||
write(data, promise: promise)
|
||||
return promise.futureResult
|
||||
|
@ -138,7 +138,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - parameters:
|
||||
/// - data: the data to write
|
||||
/// - returns: the future which will be notified once the `write` operation completes.
|
||||
public func writeAndFlush(_ data: NIOAny, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
public func writeAndFlush(_ data: NIOAny, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
let promise = makePromise(file: file, line: line)
|
||||
writeAndFlush(data, promise: promise)
|
||||
return promise.futureResult
|
||||
|
@ -149,7 +149,7 @@ extension ChannelOutboundInvoker {
|
|||
/// - parameters:
|
||||
/// - mode: the `CloseMode` that is used
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
public func close(mode: CloseMode = .all, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
public func close(mode: CloseMode = .all, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
let promise = makePromise(file: file, line: line)
|
||||
close(mode: mode, promise: promise)
|
||||
return promise.futureResult
|
||||
|
@ -160,13 +160,13 @@ extension ChannelOutboundInvoker {
|
|||
/// - parameters:
|
||||
/// - event: the event itself.
|
||||
/// - returns: the future which will be notified once the operation completes.
|
||||
public func triggerUserOutboundEvent(_ event: Any, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
public func triggerUserOutboundEvent(_ event: Any, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Void> {
|
||||
let promise = makePromise(file: file, line: line)
|
||||
triggerUserOutboundEvent(event, promise: promise)
|
||||
return promise.futureResult
|
||||
}
|
||||
|
||||
private func makePromise(file: StaticString = #file, line: UInt = #line) -> EventLoopPromise<Void> {
|
||||
private func makePromise(file: StaticString = #fileID, line: UInt = #line) -> EventLoopPromise<Void> {
|
||||
return eventLoop.makePromise(file: file, line: line)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
extension EventLoop {
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func makeFailedFuture<T>(_ error: Error, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<T> {
|
||||
public func makeFailedFuture<T>(_ error: Error, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<T> {
|
||||
return self.makeFailedFuture(error)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func makeSucceededFuture<Success>(_ value: Success, file: StaticString = #file, line: UInt = #line) -> EventLoopFuture<Success> {
|
||||
public func makeSucceededFuture<Success>(_ value: Success, file: StaticString = #fileID, line: UInt = #line) -> EventLoopFuture<Success> {
|
||||
return self.makeSucceededFuture(value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -686,7 +686,7 @@ extension EventLoop {
|
|||
|
||||
@inlinable
|
||||
func _submit<T>(_ task: @escaping SubmitCallback<T>) -> EventLoopFuture<T> {
|
||||
let promise: EventLoopPromise<T> = makePromise(file: #file, line: #line)
|
||||
let promise: EventLoopPromise<T> = makePromise(file: #fileID, line: #line)
|
||||
|
||||
self.execute {
|
||||
do {
|
||||
|
@ -749,7 +749,7 @@ extension EventLoop {
|
|||
@preconcurrency
|
||||
public func flatScheduleTask<T>(
|
||||
deadline: NIODeadline,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #fileID,
|
||||
line: UInt = #line,
|
||||
_ task: @escaping @Sendable () throws -> EventLoopFuture<T>
|
||||
) -> Scheduled<T> {
|
||||
|
@ -769,7 +769,7 @@ extension EventLoop {
|
|||
@inlinable
|
||||
public func flatScheduleTask<T>(
|
||||
deadline: NIODeadline,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #fileID,
|
||||
line: UInt = #line,
|
||||
_ task: @escaping () throws -> EventLoopFuture<T>
|
||||
) -> Scheduled<T> {
|
||||
|
@ -786,7 +786,7 @@ extension EventLoop {
|
|||
line: UInt,
|
||||
_ task: @escaping FlatScheduleTaskDelayCallback<T>
|
||||
) -> Scheduled<T> {
|
||||
let promise: EventLoopPromise<T> = self.makePromise(file:#file, line: line)
|
||||
let promise: EventLoopPromise<T> = self.makePromise(file: file, line: line)
|
||||
let scheduled = self.scheduleTask(deadline: deadline, task)
|
||||
|
||||
scheduled.futureResult.flatMap { $0 }.cascade(to: promise)
|
||||
|
@ -807,7 +807,7 @@ extension EventLoop {
|
|||
@preconcurrency
|
||||
public func flatScheduleTask<T>(
|
||||
in delay: TimeAmount,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #fileID,
|
||||
line: UInt = #line,
|
||||
_ task: @escaping @Sendable () throws -> EventLoopFuture<T>
|
||||
) -> Scheduled<T> {
|
||||
|
@ -827,7 +827,7 @@ extension EventLoop {
|
|||
@inlinable
|
||||
public func flatScheduleTask<T>(
|
||||
in delay: TimeAmount,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #fileID,
|
||||
line: UInt = #line,
|
||||
_ task: @escaping () throws -> EventLoopFuture<T>
|
||||
) -> Scheduled<T> {
|
||||
|
@ -852,7 +852,7 @@ extension EventLoop {
|
|||
|
||||
/// Creates and returns a new `EventLoopPromise` that will be notified using this `EventLoop` as execution `NIOThread`.
|
||||
@inlinable
|
||||
public func makePromise<T>(of type: T.Type = T.self, file: StaticString = #file, line: UInt = #line) -> EventLoopPromise<T> {
|
||||
public func makePromise<T>(of type: T.Type = T.self, file: StaticString = #fileID, line: UInt = #line) -> EventLoopPromise<T> {
|
||||
return EventLoopPromise<T>(eventLoop: self, file: file, line: line)
|
||||
}
|
||||
|
||||
|
@ -1069,7 +1069,7 @@ extension EventLoop {
|
|||
///
|
||||
/// - note: This is not a customization point so calls to this function can be fully optimized out in release mode.
|
||||
@inlinable
|
||||
public func assertInEventLoop(file: StaticString = #file, line: UInt = #line) {
|
||||
public func assertInEventLoop(file: StaticString = #fileID, line: UInt = #line) {
|
||||
debugOnly {
|
||||
self.preconditionInEventLoop(file: file, line: line)
|
||||
}
|
||||
|
@ -1081,7 +1081,7 @@ extension EventLoop {
|
|||
///
|
||||
/// - note: This is not a customization point so calls to this function can be fully optimized out in release mode.
|
||||
@inlinable
|
||||
public func assertNotInEventLoop(file: StaticString = #file, line: UInt = #line) {
|
||||
public func assertNotInEventLoop(file: StaticString = #fileID, line: UInt = #line) {
|
||||
debugOnly {
|
||||
self.preconditionNotInEventLoop(file: file, line: line)
|
||||
}
|
||||
|
@ -1089,13 +1089,13 @@ extension EventLoop {
|
|||
|
||||
/// Checks the necessary condition of currently running on the called `EventLoop` for making forward progress.
|
||||
@inlinable
|
||||
public func preconditionInEventLoop(file: StaticString = #file, line: UInt = #line) {
|
||||
public func preconditionInEventLoop(file: StaticString = #fileID, line: UInt = #line) {
|
||||
precondition(self.inEventLoop, file: file, line: line)
|
||||
}
|
||||
|
||||
/// Checks the necessary condition of currently _not_ running on the called `EventLoop` for making forward progress.
|
||||
@inlinable
|
||||
public func preconditionNotInEventLoop(file: StaticString = #file, line: UInt = #line) {
|
||||
public func preconditionNotInEventLoop(file: StaticString = #fileID, line: UInt = #line) {
|
||||
precondition(!self.inEventLoop, file: file, line: line)
|
||||
}
|
||||
}
|
||||
|
@ -1184,7 +1184,7 @@ extension EventLoopGroup {
|
|||
#endif
|
||||
|
||||
public func syncShutdownGracefully() throws {
|
||||
self._preconditionSafeToSyncShutdown(file: #file, line: #line)
|
||||
self._preconditionSafeToSyncShutdown(file: #fileID, line: #line)
|
||||
|
||||
let errorStorageLock = NIOLock()
|
||||
var errorStorage: Error? = nil
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
extension EventLoopFuture {
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func flatMap<NewValue>(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Value) -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue> {
|
||||
public func flatMap<NewValue>(file: StaticString = #fileID, line: UInt = #line, _ callback: @escaping (Value) -> EventLoopFuture<NewValue>) -> EventLoopFuture<NewValue> {
|
||||
return self.flatMap(callback)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func flatMapThrowing<NewValue>(file: StaticString = #file,
|
||||
public func flatMapThrowing<NewValue>(file: StaticString = #fileID,
|
||||
line: UInt = #line,
|
||||
_ callback: @escaping (Value) throws -> NewValue) -> EventLoopFuture<NewValue> {
|
||||
return self.flatMapThrowing(callback)
|
||||
|
@ -29,25 +29,25 @@ extension EventLoopFuture {
|
|||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func flatMapErrorThrowing(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Error) throws -> Value) -> EventLoopFuture<Value> {
|
||||
public func flatMapErrorThrowing(file: StaticString = #fileID, line: UInt = #line, _ callback: @escaping (Error) throws -> Value) -> EventLoopFuture<Value> {
|
||||
return self.flatMapErrorThrowing(callback)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func map<NewValue>(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Value) -> (NewValue)) -> EventLoopFuture<NewValue> {
|
||||
public func map<NewValue>(file: StaticString = #fileID, line: UInt = #line, _ callback: @escaping (Value) -> (NewValue)) -> EventLoopFuture<NewValue> {
|
||||
return self.map(callback)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func flatMapError(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Error) -> EventLoopFuture<Value>) -> EventLoopFuture<Value> {
|
||||
public func flatMapError(file: StaticString = #fileID, line: UInt = #line, _ callback: @escaping (Error) -> EventLoopFuture<Value>) -> EventLoopFuture<Value> {
|
||||
return self.flatMapError(callback)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func flatMapResult<NewValue, SomeError: Error>(file: StaticString = #file,
|
||||
public func flatMapResult<NewValue, SomeError: Error>(file: StaticString = #fileID,
|
||||
line: UInt = #line,
|
||||
_ body: @escaping (Value) -> Result<NewValue, SomeError>) -> EventLoopFuture<NewValue> {
|
||||
return self.flatMapResult(body)
|
||||
|
@ -55,14 +55,14 @@ extension EventLoopFuture {
|
|||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func recover(file: StaticString = #file, line: UInt = #line, _ callback: @escaping (Error) -> Value) -> EventLoopFuture<Value> {
|
||||
public func recover(file: StaticString = #fileID, line: UInt = #line, _ callback: @escaping (Error) -> Value) -> EventLoopFuture<Value> {
|
||||
return self.recover(callback)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func and<OtherValue>(_ other: EventLoopFuture<OtherValue>,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #fileID,
|
||||
line: UInt = #line) -> EventLoopFuture<(Value, OtherValue)> {
|
||||
return self.and(other)
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ extension EventLoopFuture {
|
|||
@inlinable
|
||||
@available(*, deprecated, message: "Please don't pass file:line:, there's no point.")
|
||||
public func and<OtherValue>(value: OtherValue,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #fileID,
|
||||
line: UInt = #line) -> EventLoopFuture<(Value, OtherValue)> {
|
||||
return self.and(value: value)
|
||||
}
|
||||
|
|
|
@ -1235,7 +1235,7 @@ extension EventLoopFuture {
|
|||
/// - returns: The value of the `EventLoopFuture` when it completes.
|
||||
/// - throws: The error value of the `EventLoopFuture` if it errors.
|
||||
@inlinable
|
||||
public func wait(file: StaticString = #file, line: UInt = #line) throws -> Value {
|
||||
public func wait(file: StaticString = #fileID, line: UInt = #line) throws -> Value {
|
||||
self.eventLoop._preconditionSafeToWait(file: file, line: line)
|
||||
|
||||
let v: UnsafeMutableTransferBox<Result<Value, Error>?> = .init(nil)
|
||||
|
|
|
@ -1050,7 +1050,7 @@ func spawnAndJoinRacingThreads(count: Int, _ body: @escaping (Int) -> Void) {
|
|||
group.wait()
|
||||
}
|
||||
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #file, line: UInt = #line) {
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #filePath, line: UInt = #line) {
|
||||
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
|
||||
let endTime = NIODeadline.now() + time
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ fileprivate struct TestCase {
|
|||
var buffers: [[UInt8]]
|
||||
var file: StaticString
|
||||
var line: UInt
|
||||
init(_ buffers: [[UInt8]], file: StaticString = #file, line: UInt = #line) {
|
||||
init(_ buffers: [[UInt8]], file: StaticString = #filePath, line: UInt = #line) {
|
||||
self.buffers = buffers
|
||||
self.file = file
|
||||
self.line = line
|
||||
|
|
|
@ -1164,7 +1164,7 @@ class ByteBufferTest: XCTestCase {
|
|||
buf.reserveCapacity(1024)
|
||||
buf.writeStaticString("hello world, just some trap bytes here")
|
||||
|
||||
func testIndexAndLengthFunc<T>(_ body: (Int, Int) -> T?, file: StaticString = #file, line: UInt = #line) {
|
||||
func testIndexAndLengthFunc<T>(_ body: (Int, Int) -> T?, file: StaticString = #filePath, line: UInt = #line) {
|
||||
XCTAssertNil(body(Int.max, 1), file: (file), line: line)
|
||||
XCTAssertNil(body(Int.max - 1, 2), file: (file), line: line)
|
||||
XCTAssertNil(body(1, Int.max), file: (file), line: line)
|
||||
|
@ -1175,7 +1175,7 @@ class ByteBufferTest: XCTestCase {
|
|||
XCTAssertNil(body(Int.min, Int.max), file: (file), line: line)
|
||||
}
|
||||
|
||||
func testIndexOrLengthFunc<T>(_ body: (Int) -> T?, file: StaticString = #file, line: UInt = #line) {
|
||||
func testIndexOrLengthFunc<T>(_ body: (Int) -> T?, file: StaticString = #filePath, line: UInt = #line) {
|
||||
XCTAssertNil(body(Int.max))
|
||||
XCTAssertNil(body(Int.max - 1))
|
||||
XCTAssertNil(body(Int.min))
|
||||
|
|
|
@ -90,7 +90,7 @@ final class AdaptiveRecvByteBufferAllocatorTest: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
private func testActualReadBytes(mayGrow: Bool, actualReadBytes: Int, expectedCapacity: Int, file: StaticString = #file, line: UInt = #line) {
|
||||
private func testActualReadBytes(mayGrow: Bool, actualReadBytes: Int, expectedCapacity: Int, file: StaticString = #filePath, line: UInt = #line) {
|
||||
XCTAssertEqual(mayGrow, adaptive.record(actualReadBytes: actualReadBytes), "unexpected value for mayGrow", file: file, line: line)
|
||||
let buffer = adaptive.buffer(allocator: allocator)
|
||||
XCTAssertEqual(expectedCapacity, buffer.capacity, "unexpected capacity", file: file, line: line)
|
||||
|
|
|
@ -77,7 +77,7 @@ extension XCTestCase {
|
|||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func XCTAssertThrowsError<T>(
|
||||
_ expression: @autoclosure () async throws -> T,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
verify: (Error) -> Void = { _ in }
|
||||
) async {
|
||||
|
@ -105,7 +105,7 @@ internal func XCTAssertNoThrow<T>(
|
|||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func XCTAssertNoThrowWithResult<Result>(
|
||||
_ expression: @autoclosure () async throws -> Result,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) async -> Result? {
|
||||
do {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
import XCTest
|
||||
import NIOCore
|
||||
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #file, line: UInt = #line) {
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #filePath, line: UInt = #line) {
|
||||
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
|
||||
let endTime = NIODeadline.now() + time
|
||||
|
||||
|
@ -29,7 +29,7 @@ func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testI
|
|||
}
|
||||
}
|
||||
|
||||
func assertNoThrowWithValue<T>(_ body: @autoclosure () throws -> T, defaultValue: T? = nil, message: String? = nil, file: StaticString = #file, line: UInt = #line) throws -> T {
|
||||
func assertNoThrowWithValue<T>(_ body: @autoclosure () throws -> T, defaultValue: T? = nil, message: String? = nil, file: StaticString = #filePath, line: UInt = #line) throws -> T {
|
||||
do {
|
||||
return try body()
|
||||
} catch {
|
||||
|
|
|
@ -234,7 +234,7 @@ class AsyncTestingChannelTests: XCTestCase {
|
|||
|
||||
func check<Expected: Sendable, Actual>(expected: Expected.Type,
|
||||
actual: Actual.Type,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) async {
|
||||
do {
|
||||
_ = try await channel.readOutbound(as: Expected.self)
|
||||
|
@ -507,18 +507,18 @@ class AsyncTestingChannelTests: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
fileprivate func XCTAsyncAssertTrue(_ predicate: @autoclosure () async throws -> Bool, file: StaticString = #file, line: UInt = #line) async rethrows {
|
||||
fileprivate func XCTAsyncAssertTrue(_ predicate: @autoclosure () async throws -> Bool, file: StaticString = #filePath, line: UInt = #line) async rethrows {
|
||||
let result = try await predicate()
|
||||
XCTAssertTrue(result, file: file, line: line)
|
||||
}
|
||||
|
||||
fileprivate func XCTAsyncAssertEqual<Element: Equatable>(_ lhs: @autoclosure () async throws -> Element, _ rhs: @autoclosure () async throws -> Element, file: StaticString = #file, line: UInt = #line) async rethrows {
|
||||
fileprivate func XCTAsyncAssertEqual<Element: Equatable>(_ lhs: @autoclosure () async throws -> Element, _ rhs: @autoclosure () async throws -> Element, file: StaticString = #filePath, line: UInt = #line) async rethrows {
|
||||
let lhsResult = try await lhs()
|
||||
let rhsResult = try await rhs()
|
||||
XCTAssertEqual(lhsResult, rhsResult, file: file, line: line)
|
||||
}
|
||||
|
||||
fileprivate func XCTAsyncAssertThrowsError<ResultType>(_ expression: @autoclosure () async throws -> ResultType, file: StaticString = #file, line: UInt = #line, _ callback: Optional<(Error) -> Void> = nil) async {
|
||||
fileprivate func XCTAsyncAssertThrowsError<ResultType>(_ expression: @autoclosure () async throws -> ResultType, file: StaticString = #filePath, line: UInt = #line, _ callback: Optional<(Error) -> Void> = nil) async {
|
||||
do {
|
||||
let _ = try await expression()
|
||||
XCTFail("Did not throw", file: file, line: line)
|
||||
|
@ -527,12 +527,12 @@ fileprivate func XCTAsyncAssertThrowsError<ResultType>(_ expression: @autoclosur
|
|||
}
|
||||
}
|
||||
|
||||
fileprivate func XCTAsyncAssertNil(_ expression: @autoclosure () async throws -> Any?, file: StaticString = #file, line: UInt = #line) async rethrows {
|
||||
fileprivate func XCTAsyncAssertNil(_ expression: @autoclosure () async throws -> Any?, file: StaticString = #filePath, line: UInt = #line) async rethrows {
|
||||
let result = try await expression()
|
||||
XCTAssertNil(result, file: file, line: line)
|
||||
}
|
||||
|
||||
fileprivate func XCTAsyncAssertNotNil(_ expression: @autoclosure () async throws -> Any?, file: StaticString = #file, line: UInt = #line) async rethrows {
|
||||
fileprivate func XCTAsyncAssertNotNil(_ expression: @autoclosure () async throws -> Any?, file: StaticString = #filePath, line: UInt = #line) async rethrows {
|
||||
let result = try await expression()
|
||||
XCTAssertNotNil(result, file: file, line: line)
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ class EmbeddedChannelTest: XCTestCase {
|
|||
|
||||
func check<Expected, Actual>(expected: Expected.Type,
|
||||
actual: Actual.Type,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) {
|
||||
do {
|
||||
_ = try channel.readOutbound(as: Expected.self)
|
||||
|
|
|
@ -18,7 +18,7 @@ import NIOCore
|
|||
import NIOConcurrencyHelpers
|
||||
|
||||
// FIXME: Duplicated with NIO
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #file, line: UInt = #line) {
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #filePath, line: UInt = #line) {
|
||||
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
|
||||
let endTime = NIODeadline.now() + time
|
||||
|
||||
|
@ -65,7 +65,7 @@ internal func XCTAssertCompareAndSwapSucceeds<Type: AtomicValue>(
|
|||
storage: ManagedAtomic<Type>,
|
||||
expected: Type,
|
||||
desired: Type,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
let result = storage.compareExchange(expected: expected, desired: desired, ordering: .relaxed)
|
||||
|
|
|
@ -77,7 +77,7 @@ extension XCTestCase {
|
|||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func XCTAssertThrowsError<T>(
|
||||
_ expression: @autoclosure () async throws -> T,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
verify: (Error) -> Void = { _ in }
|
||||
) async {
|
||||
|
@ -92,7 +92,7 @@ internal func XCTAssertThrowsError<T>(
|
|||
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
|
||||
internal func XCTAssertNoThrowWithResult<Result>(
|
||||
_ expression: @autoclosure () async throws -> Result,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) async -> Result? {
|
||||
do {
|
||||
|
|
|
@ -25,7 +25,7 @@ extension ChannelPipeline {
|
|||
}
|
||||
|
||||
func assertDoesNotContain<Handler: ChannelHandler>(handlerType: Handler.Type,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) throws {
|
||||
do {
|
||||
let context = try self.context(handlerType: handlerType).wait()
|
||||
|
|
|
@ -18,7 +18,7 @@ import XCTest
|
|||
|
||||
class ChannelNotificationTest: XCTestCase {
|
||||
|
||||
private static func assertFulfilled(promise: EventLoopPromise<Void>?, promiseName: String, trigger: String, setter: String, file: StaticString = #file, line: UInt = #line) {
|
||||
private static func assertFulfilled(promise: EventLoopPromise<Void>?, promiseName: String, trigger: String, setter: String, file: StaticString = #filePath, line: UInt = #line) {
|
||||
if let promise = promise {
|
||||
XCTAssertTrue(promise.futureResult.isFulfilled, "\(promiseName) not fulfilled before \(trigger) was called", file: (file), line: line)
|
||||
} else {
|
||||
|
|
|
@ -257,7 +257,7 @@ public final class ChannelTests: XCTestCase {
|
|||
expectedFileWritabilities: [(Int, Int)]?,
|
||||
returns: [NIOPosix.IOResult<Int>],
|
||||
promiseStates: [[Bool]],
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) throws -> OverallWriteResult {
|
||||
var everythingState = 0
|
||||
var singleState = 0
|
||||
|
@ -1961,7 +1961,7 @@ public final class ChannelTests: XCTestCase {
|
|||
}
|
||||
|
||||
func testAppropriateAndInappropriateOperationsForUnregisteredSockets() throws {
|
||||
func checkThatItThrowsInappropriateOperationForState(file: StaticString = #file, line: UInt = #line, _ body: () throws -> Void) {
|
||||
func checkThatItThrowsInappropriateOperationForState(file: StaticString = #filePath, line: UInt = #line, _ body: () throws -> Void) {
|
||||
XCTAssertThrowsError(try body(), file: (file), line: line) { error in
|
||||
XCTAssertEqual(.inappropriateOperationForState, error as? ChannelError)
|
||||
}
|
||||
|
@ -1971,7 +1971,7 @@ public final class ChannelTests: XCTestCase {
|
|||
XCTAssertNoThrow(try elg.syncShutdownGracefully())
|
||||
}
|
||||
|
||||
func withChannel(skipDatagram: Bool = false, skipStream: Bool = false, skipServerSocket: Bool = false, file: StaticString = #file, line: UInt = #line, _ body: (Channel) throws -> Void) {
|
||||
func withChannel(skipDatagram: Bool = false, skipStream: Bool = false, skipServerSocket: Bool = false, file: StaticString = #filePath, line: UInt = #line, _ body: (Channel) throws -> Void) {
|
||||
XCTAssertNoThrow(try {
|
||||
let el = elg.next() as! SelectableEventLoop
|
||||
let channels: [Channel] = (skipDatagram ? [] : [try DatagramChannel(eventLoop: el, protocolFamily: .inet)]) +
|
||||
|
|
|
@ -1635,7 +1635,7 @@ public final class MessageToByteEncoderTest: XCTestCase {
|
|||
try testEncoder(MessageToByteHandler(Int32ToByteEncoderWithDefaultImpl()))
|
||||
}
|
||||
|
||||
private func testEncoder(_ handler: ChannelHandler, file: StaticString = #file, line: UInt = #line) throws {
|
||||
private func testEncoder(_ handler: ChannelHandler, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
let channel = EmbeddedChannel()
|
||||
|
||||
XCTAssertNoThrow(try channel.pipeline.addHandler(MessageToByteHandler(Int32ToByteEncoder())).wait(),
|
||||
|
|
|
@ -93,7 +93,7 @@ class ControlMessageTests: XCTestCase {
|
|||
|
||||
private func assertBuffersNonOverlapping(_ b1: UnsafeMutableRawBufferPointer,
|
||||
_ b2: UnsafeMutableRawBufferPointer,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) {
|
||||
XCTAssert((b1.baseAddress! < b2.baseAddress! && (b1.baseAddress! + b1.count) <= b2.baseAddress!) ||
|
||||
(b2.baseAddress! < b1.baseAddress! && (b2.baseAddress! + b2.count) <= b1.baseAddress!),
|
||||
|
|
|
@ -920,7 +920,7 @@ class DatagramChannelTests: XCTestCase {
|
|||
to destinationChannel: Channel,
|
||||
wrappingInAddressedEnvelope shouldWrapInAddressedEnvelope: Bool,
|
||||
resultsIn expectedResult: Result<Void, Error>,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) throws {
|
||||
// Wrap data in AddressedEnvelope if required.
|
||||
|
@ -964,7 +964,7 @@ class DatagramChannelTests: XCTestCase {
|
|||
to destinationChannel: Channel,
|
||||
wrappingInAddressedEnvelope shouldWrapInAddressedEnvelope: Bool,
|
||||
resultsIn expectedResult: Result<Void, Error>,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) throws {
|
||||
try self.assertSending(
|
||||
|
|
|
@ -512,7 +512,7 @@ class EventLoopFutureTest : XCTestCase {
|
|||
func testOrderOfFutureCompletion() throws {
|
||||
let eventLoop = EmbeddedEventLoop()
|
||||
var state = 0
|
||||
let p: EventLoopPromise<Void> = EventLoopPromise(eventLoop: eventLoop, file: #file, line: #line)
|
||||
let p: EventLoopPromise<Void> = EventLoopPromise(eventLoop: eventLoop, file: #filePath, line: #line)
|
||||
p.futureResult.map {
|
||||
XCTAssertEqual(state, 0)
|
||||
state += 1
|
||||
|
|
|
@ -532,7 +532,7 @@ public final class EventLoopTest : XCTestCase {
|
|||
XCTAssertNoThrow(try serverChannelUp.futureResult.wait())
|
||||
|
||||
let g = DispatchGroup()
|
||||
let q = DispatchQueue(label: "\(#file)/\(#line)")
|
||||
let q = DispatchQueue(label: "\(#filePath)/\(#line)")
|
||||
g.enter()
|
||||
// Now we're going to start closing the event loop. This should not immediately succeed.
|
||||
loop.initiateClose(queue: q) { result in
|
||||
|
|
|
@ -174,7 +174,7 @@ final class MulticastTest: XCTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
private func assertDatagramReaches(multicastChannel: Channel, sender: Channel, multicastAddress: SocketAddress, file: StaticString = #file, line: UInt = #line) throws {
|
||||
private func assertDatagramReaches(multicastChannel: Channel, sender: Channel, multicastAddress: SocketAddress, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
let receivedMulticastDatagram = multicastChannel.eventLoop.makePromise(of: AddressedEnvelope<ByteBuffer>.self)
|
||||
XCTAssertNoThrow(try multicastChannel.pipeline.addHandler(PromiseOnReadHandler(promise: receivedMulticastDatagram)).wait())
|
||||
|
||||
|
@ -196,7 +196,7 @@ final class MulticastTest: XCTestCase {
|
|||
after timeout: TimeAmount,
|
||||
sender: Channel,
|
||||
multicastAddress: SocketAddress,
|
||||
file: StaticString = #file, line: UInt = #line) throws {
|
||||
file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
let timeoutPromise = multicastChannel.eventLoop.makePromise(of: Void.self)
|
||||
let receivedMulticastDatagram = multicastChannel.eventLoop.makePromise(of: AddressedEnvelope<ByteBuffer>.self)
|
||||
XCTAssertNoThrow(try multicastChannel.pipeline.addHandler(PromiseOnReadHandler(promise: receivedMulticastDatagram)).wait())
|
||||
|
|
|
@ -108,7 +108,7 @@ class PendingDatagramWritesManagerTests: XCTestCase {
|
|||
expectedVectorWritabilities: [[(Int, SocketAddress)]]?,
|
||||
returns: [Result<NIOPosix.IOResult<Int>, Error>],
|
||||
promiseStates: [[Bool]],
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) throws -> OverallWriteResult {
|
||||
var everythingState = 0
|
||||
var singleState = 0
|
||||
|
|
|
@ -25,7 +25,7 @@ final class SocketOptionProviderTest: XCTestCase {
|
|||
|
||||
struct CastError: Error { }
|
||||
|
||||
private func convertedChannel(file: StaticString = #file, line: UInt = #line) throws -> SocketOptionProvider {
|
||||
private func convertedChannel(file: StaticString = #filePath, line: UInt = #line) throws -> SocketOptionProvider {
|
||||
guard let provider = self.clientChannel as? SocketOptionProvider else {
|
||||
XCTFail("Unable to cast \(String(describing: self.clientChannel)) to SocketOptionProvider", file: (file), line: line)
|
||||
throw CastError()
|
||||
|
@ -33,7 +33,7 @@ final class SocketOptionProviderTest: XCTestCase {
|
|||
return provider
|
||||
}
|
||||
|
||||
private func ipv4MulticastProvider(file: StaticString = #file, line: UInt = #line) throws -> SocketOptionProvider {
|
||||
private func ipv4MulticastProvider(file: StaticString = #filePath, line: UInt = #line) throws -> SocketOptionProvider {
|
||||
guard let provider = self.ipv4DatagramChannel as? SocketOptionProvider else {
|
||||
XCTFail("Unable to cast \(String(describing: self.ipv4DatagramChannel)) to SocketOptionProvider", file: (file), line: line)
|
||||
throw CastError()
|
||||
|
@ -41,7 +41,7 @@ final class SocketOptionProviderTest: XCTestCase {
|
|||
return provider
|
||||
}
|
||||
|
||||
private func ipv6MulticastProvider(file: StaticString = #file, line: UInt = #line) throws -> SocketOptionProvider? {
|
||||
private func ipv6MulticastProvider(file: StaticString = #filePath, line: UInt = #line) throws -> SocketOptionProvider? {
|
||||
guard let ipv6Channel = self.ipv6DatagramChannel else {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -890,7 +890,7 @@ final class AccumulateAllReads: ChannelInboundHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private func assertNoSelectorChanges(fd: CInt, selector: NIOPosix.Selector<NIORegistration>, file: StaticString = #file, line: UInt = #line) throws {
|
||||
private func assertNoSelectorChanges(fd: CInt, selector: NIOPosix.Selector<NIORegistration>, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
struct UnexpectedSelectorChanges: Error, CustomStringConvertible {
|
||||
let description: String
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ final class LockedBox<T> {
|
|||
|
||||
init(_ value: T? = nil,
|
||||
description: String? = nil,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
didSet: @escaping (T?) -> Void = { _ in }) {
|
||||
self._value = value
|
||||
|
@ -116,7 +116,7 @@ final class LockedBox<T> {
|
|||
}
|
||||
|
||||
extension LockedBox where T == UserToKernel {
|
||||
func assertParkedRightNow(file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertParkedRightNow(file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
let syscall = try self.waitForValue()
|
||||
if case .whenReady(.block) = syscall {
|
||||
|
@ -389,7 +389,7 @@ class HookedSocket: Socket, UserKernelInterface {
|
|||
|
||||
extension HookedSelector {
|
||||
func assertSyscallAndReturn(_ result: KernelToUser,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
matcher: (UserToKernel) throws -> Bool) throws {
|
||||
let syscall = try self.userToKernel.takeValue()
|
||||
|
@ -405,7 +405,7 @@ extension HookedSelector {
|
|||
/// is currently executing then it will not be woken: as a result, consider using
|
||||
/// `assertParkedRightNow` before the event that you want to trigger the wakeup, and before calling
|
||||
/// this code.
|
||||
func assertWakeup(file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertWakeup(file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.wakeups.takeValue()
|
||||
try self.assertSyscallAndReturn(.returnSelectorEvent(nil), file: (file), line: line) { syscall in
|
||||
|
@ -417,14 +417,14 @@ extension HookedSelector {
|
|||
}
|
||||
}
|
||||
|
||||
func assertParkedRightNow(file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertParkedRightNow(file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
try self.userToKernel.assertParkedRightNow(file: file, line: line)
|
||||
}
|
||||
}
|
||||
|
||||
extension EventLoop {
|
||||
internal func runSAL<T>(syscallAssertions: () throws -> Void = {},
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: @escaping () throws -> T) throws -> T {
|
||||
let hookedSelector = ((self as! SelectableEventLoop)._selector as! HookedSelector)
|
||||
|
@ -511,7 +511,7 @@ extension SALTest {
|
|||
}
|
||||
|
||||
private func makeSocketChannel(eventLoop: SelectableEventLoop,
|
||||
file: StaticString = #file, line: UInt = #line) throws -> SocketChannel {
|
||||
file: StaticString = #filePath, line: UInt = #line) throws -> SocketChannel {
|
||||
let channel = try eventLoop.runSAL(syscallAssertions: {
|
||||
try self.assertdisableSIGPIPE(expectedFD: .max, result: .success(()))
|
||||
try self.assertLocalAddress(address: nil)
|
||||
|
@ -548,13 +548,13 @@ extension SALTest {
|
|||
return channel
|
||||
}
|
||||
|
||||
func makeSocketChannel(file: StaticString = #file, line: UInt = #line) throws -> SocketChannel {
|
||||
func makeSocketChannel(file: StaticString = #filePath, line: UInt = #line) throws -> SocketChannel {
|
||||
return try self.makeSocketChannel(eventLoop: self.loop, file: (file), line: line)
|
||||
}
|
||||
|
||||
func makeConnectedSocketChannel(localAddress: SocketAddress?,
|
||||
remoteAddress: SocketAddress,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) throws -> SocketChannel {
|
||||
let channel = try self.makeSocketChannel(eventLoop: self.loop)
|
||||
let connectFuture = try channel.eventLoop.runSAL(syscallAssertions: {
|
||||
|
@ -617,12 +617,12 @@ extension SALTest {
|
|||
self.wakeups = nil
|
||||
}
|
||||
|
||||
func assertParkedRightNow(file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertParkedRightNow(file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
try self.userToKernelBox.assertParkedRightNow(file: file, line: line)
|
||||
}
|
||||
|
||||
func assertWaitingForNotification(result: SelectorEvent<NIORegistration>?,
|
||||
file: StaticString = #file, line: UInt = #line) throws {
|
||||
file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)(result: \(result.debugDescription))")
|
||||
try self.selector.assertSyscallAndReturn(.returnSelectorEvent(result),
|
||||
file: (file), line: line) { syscall in
|
||||
|
@ -634,13 +634,13 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertWakeup(file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertWakeup(file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
try self.selector.assertWakeup(file: (file), line: line)
|
||||
}
|
||||
|
||||
func assertdisableSIGPIPE(expectedFD: CInt,
|
||||
result: Result<Void, IOError>,
|
||||
file: StaticString = #file, line: UInt = #line) throws {
|
||||
file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
let ret: KernelToUser
|
||||
switch result {
|
||||
|
@ -659,7 +659,7 @@ extension SALTest {
|
|||
}
|
||||
|
||||
|
||||
func assertLocalAddress(address: SocketAddress?, file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertLocalAddress(address: SocketAddress?, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(address.map {
|
||||
.returnSocketAddress($0)
|
||||
|
@ -673,7 +673,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertRemoteAddress(address: SocketAddress?, file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertRemoteAddress(address: SocketAddress?, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(address.map { .returnSocketAddress($0) } ??
|
||||
/* */ .error(.init(errnoCode: EOPNOTSUPP, reason: "nil passed")),
|
||||
|
@ -686,7 +686,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertConnect(expectedAddress: SocketAddress, result: Bool, file: StaticString = #file, line: UInt = #line, _ matcher: (SocketAddress) -> Bool = { _ in true }) throws {
|
||||
func assertConnect(expectedAddress: SocketAddress, result: Bool, file: StaticString = #filePath, line: UInt = #line, _ matcher: (SocketAddress) -> Bool = { _ in true }) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnBool(result), file: (file), line: line) { syscall in
|
||||
if case .connect(let address) = syscall {
|
||||
|
@ -697,7 +697,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertBind(expectedAddress: SocketAddress, file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertBind(expectedAddress: SocketAddress, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnVoid, file: (file), line: line) { syscall in
|
||||
if case .bind(let address) = syscall {
|
||||
|
@ -708,7 +708,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertClose(expectedFD: CInt, file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertClose(expectedFD: CInt, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnVoid, file: (file), line: line) { syscall in
|
||||
if case .close(let fd) = syscall {
|
||||
|
@ -722,7 +722,7 @@ extension SALTest {
|
|||
|
||||
func assertSetOption(expectedLevel: NIOBSDSocket.OptionLevel,
|
||||
expectedOption: NIOBSDSocket.Option,
|
||||
file: StaticString = #file, line: UInt = #line,
|
||||
file: StaticString = #filePath, line: UInt = #line,
|
||||
_ valueMatcher: (Any) -> Bool = { _ in true }) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnVoid, file: (file), line: line) { syscall in
|
||||
|
@ -734,7 +734,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertRegister(file: StaticString = #file, line: UInt = #line, _ matcher: (Selectable, SelectorEventSet, NIORegistration) throws -> Bool) throws {
|
||||
func assertRegister(file: StaticString = #filePath, line: UInt = #line, _ matcher: (Selectable, SelectorEventSet, NIORegistration) throws -> Bool) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnVoid, file: (file), line: line) { syscall in
|
||||
if case .register(let selectable, let eventSet, let registration) = syscall {
|
||||
|
@ -745,7 +745,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertReregister(file: StaticString = #file, line: UInt = #line, _ matcher: (Selectable, SelectorEventSet) throws -> Bool) throws {
|
||||
func assertReregister(file: StaticString = #filePath, line: UInt = #line, _ matcher: (Selectable, SelectorEventSet) throws -> Bool) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnVoid, file: (file), line: line) { syscall in
|
||||
if case .reregister(let selectable, let eventSet) = syscall {
|
||||
|
@ -756,7 +756,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertDeregister(file: StaticString = #file, line: UInt = #line, _ matcher: (Selectable) throws -> Bool) throws {
|
||||
func assertDeregister(file: StaticString = #filePath, line: UInt = #line, _ matcher: (Selectable) throws -> Bool) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnVoid, file: (file), line: line) { syscall in
|
||||
if case .deregister(let selectable) = syscall {
|
||||
|
@ -767,7 +767,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertWrite(expectedFD: CInt, expectedBytes: ByteBuffer, return: IOResult<Int>, file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertWrite(expectedFD: CInt, expectedBytes: ByteBuffer, return: IOResult<Int>, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnIOResultInt(`return`), file: (file), line: line) { syscall in
|
||||
if case .write(let actualFD, let actualBytes) = syscall {
|
||||
|
@ -778,7 +778,7 @@ extension SALTest {
|
|||
}
|
||||
}
|
||||
|
||||
func assertWritev(expectedFD: CInt, expectedBytes: [ByteBuffer], return: IOResult<Int>, file: StaticString = #file, line: UInt = #line) throws {
|
||||
func assertWritev(expectedFD: CInt, expectedBytes: [ByteBuffer], return: IOResult<Int>, file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnIOResultInt(`return`), file: (file), line: line) { syscall in
|
||||
if case .writev(let actualFD, let actualBytes) = syscall {
|
||||
|
@ -790,7 +790,7 @@ extension SALTest {
|
|||
}
|
||||
|
||||
func assertRead(expectedFD: CInt, expectedBufferSpace: Int, return: ByteBuffer,
|
||||
file: StaticString = #file, line: UInt = #line) throws {
|
||||
file: StaticString = #filePath, line: UInt = #line) throws {
|
||||
SAL.printIfDebug("\(#function)")
|
||||
try self.selector.assertSyscallAndReturn(.returnBytes(`return`),
|
||||
file: (file), line: line) { syscall in
|
||||
|
|
|
@ -121,5 +121,5 @@ func runSystemCallWrapperPerformanceTest(testAssertFunction: (@autoclosure () ->
|
|||
}
|
||||
testAssertFunction(directCallTime * (1.0 + Double(allowedOverheadPercent)/100) > withSystemCallWrappersTime,
|
||||
"Posix wrapper adds more than \(allowedOverheadPercent)% overhead (with wrapper: \(withSystemCallWrappersTime), without: \(directCallTime)",
|
||||
#file, #line)
|
||||
#filePath, #line)
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ func assertSetGetOptionOnOpenAndClosed<Option: ChannelOption>(channel: Channel,
|
|||
}
|
||||
}
|
||||
|
||||
func assertNoThrowWithValue<T>(_ body: @autoclosure () throws -> T, defaultValue: T? = nil, message: String? = nil, file: StaticString = #file, line: UInt = #line) throws -> T {
|
||||
func assertNoThrowWithValue<T>(_ body: @autoclosure () throws -> T, defaultValue: T? = nil, message: String? = nil, file: StaticString = #filePath, line: UInt = #line) throws -> T {
|
||||
do {
|
||||
return try body()
|
||||
} catch {
|
||||
|
@ -291,7 +291,7 @@ func resolverDebugInformation(eventLoop: EventLoop, host: String, previouslyRece
|
|||
"""
|
||||
}
|
||||
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #file, line: UInt = #line) {
|
||||
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = #filePath, line: UInt = #line) {
|
||||
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
|
||||
let endTime = NIODeadline.now() + time
|
||||
|
||||
|
@ -306,15 +306,15 @@ func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testI
|
|||
}
|
||||
|
||||
func getBoolSocketOption(channel: Channel, level: NIOBSDSocket.OptionLevel, name: NIOBSDSocket.Option,
|
||||
file: StaticString = #file, line: UInt = #line) throws -> Bool {
|
||||
file: StaticString = #filePath, line: UInt = #line) throws -> Bool {
|
||||
return try assertNoThrowWithValue(channel.getOption(ChannelOptions.Types.SocketOption(level: level, name: name)), file: (file), line: line).wait() != 0
|
||||
}
|
||||
|
||||
func assertSuccess<Value>(_ result: Result<Value, Error>, file: StaticString = #file, line: UInt = #line) {
|
||||
func assertSuccess<Value>(_ result: Result<Value, Error>, file: StaticString = #filePath, line: UInt = #line) {
|
||||
guard case .success = result else { return XCTFail("Expected result to be successful", file: (file), line: line) }
|
||||
}
|
||||
|
||||
func assertFailure<Value>(_ result: Result<Value, Error>, file: StaticString = #file, line: UInt = #line) {
|
||||
func assertFailure<Value>(_ result: Result<Value, Error>, file: StaticString = #filePath, line: UInt = #line) {
|
||||
guard case .failure = result else { return XCTFail("Expected result to be a failure", file: (file), line: line) }
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ final class FulfillOnFirstEventHandler: ChannelDuplexHandler {
|
|||
}
|
||||
}
|
||||
|
||||
func forEachActiveChannelType<T>(file: StaticString = #file,
|
||||
func forEachActiveChannelType<T>(file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: @escaping (Channel) throws -> T) throws -> [T] {
|
||||
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
|
@ -527,7 +527,7 @@ func forEachActiveChannelType<T>(file: StaticString = #file,
|
|||
|
||||
func withTCPServerChannel<R>(bindTarget: SocketAddress? = nil,
|
||||
group: EventLoopGroup,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: (Channel) throws -> R) throws -> R {
|
||||
let server = try ServerBootstrap(group: group)
|
||||
|
@ -546,7 +546,7 @@ func withTCPServerChannel<R>(bindTarget: SocketAddress? = nil,
|
|||
|
||||
func withCrossConnectedSockAddrChannels<R>(bindTarget: SocketAddress,
|
||||
forceSeparateEventLoops: Bool = false,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: (Channel, Channel) throws -> R) throws -> R {
|
||||
let serverGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
|
@ -596,7 +596,7 @@ func withCrossConnectedSockAddrChannels<R>(bindTarget: SocketAddress,
|
|||
}
|
||||
|
||||
func withCrossConnectedTCPChannels<R>(forceSeparateEventLoops: Bool = false,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: (Channel, Channel) throws -> R) throws -> R {
|
||||
return try withCrossConnectedSockAddrChannels(bindTarget: .init(ipAddress: "127.0.0.1", port: 0),
|
||||
|
@ -605,7 +605,7 @@ func withCrossConnectedTCPChannels<R>(forceSeparateEventLoops: Bool = false,
|
|||
}
|
||||
|
||||
func withCrossConnectedUnixDomainSocketChannels<R>(forceSeparateEventLoops: Bool = false,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: (Channel, Channel) throws -> R) throws -> R {
|
||||
return try withTemporaryDirectory { tempDir in
|
||||
|
@ -617,7 +617,7 @@ func withCrossConnectedUnixDomainSocketChannels<R>(forceSeparateEventLoops: Bool
|
|||
}
|
||||
|
||||
func withCrossConnectedPipeChannels<R>(forceSeparateEventLoops: Bool = false,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: (Channel, Channel) throws -> R) throws -> R {
|
||||
let channel1Group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
|
@ -672,7 +672,7 @@ func withCrossConnectedPipeChannels<R>(forceSeparateEventLoops: Bool = false,
|
|||
}
|
||||
|
||||
func forEachCrossConnectedStreamChannelPair<R>(forceSeparateEventLoops: Bool = false,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line,
|
||||
_ body: (Channel, Channel) throws -> R) throws -> [R] {
|
||||
let r1 = try withCrossConnectedTCPChannels(forceSeparateEventLoops: forceSeparateEventLoops, body)
|
||||
|
|
|
@ -353,7 +353,7 @@ private final class TestHTTPHandler: ChannelInboundHandler {
|
|||
}
|
||||
|
||||
extension HTTPServerRequestPart {
|
||||
func assertHead(expectedURI: String, file: StaticString = #file, line: UInt = #line) {
|
||||
func assertHead(expectedURI: String, file: StaticString = #filePath, line: UInt = #line) {
|
||||
switch self {
|
||||
case .head(let head):
|
||||
XCTAssertEqual(.GET, head.method)
|
||||
|
@ -364,7 +364,7 @@ extension HTTPServerRequestPart {
|
|||
}
|
||||
}
|
||||
|
||||
func assertBody(expectedMessage: String, file: StaticString = #file, line: UInt = #line) {
|
||||
func assertBody(expectedMessage: String, file: StaticString = #filePath, line: UInt = #line) {
|
||||
switch self {
|
||||
case .body(let buffer):
|
||||
// Note that the test server coalesces the body parts for us.
|
||||
|
@ -375,7 +375,7 @@ extension HTTPServerRequestPart {
|
|||
}
|
||||
}
|
||||
|
||||
func assertEnd(file: StaticString = #file, line: UInt = #line) {
|
||||
func assertEnd(file: StaticString = #filePath, line: UInt = #line) {
|
||||
switch self {
|
||||
case .end(_):
|
||||
()
|
||||
|
@ -415,7 +415,7 @@ func assert(_ condition: @autoclosure () -> Bool,
|
|||
within time: TimeAmount,
|
||||
testInterval: TimeAmount? = nil,
|
||||
_ message: String = "condition not satisfied in time",
|
||||
file: StaticString = #file, line: UInt = #line) {
|
||||
file: StaticString = #filePath, line: UInt = #line) {
|
||||
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
|
||||
let endTime = NIODeadline.now() + time
|
||||
|
||||
|
@ -432,7 +432,7 @@ func assert(_ condition: @autoclosure () -> Bool,
|
|||
func assertNoThrowWithValue<T>(_ body: @autoclosure () throws -> T,
|
||||
defaultValue: T? = nil,
|
||||
message: String? = nil,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) throws -> T {
|
||||
do {
|
||||
return try body()
|
||||
|
|
|
@ -33,7 +33,7 @@ extension EmbeddedChannel {
|
|||
extension ChannelPipeline {
|
||||
|
||||
fileprivate func assertDoesNotContain<Handler: ChannelHandler>(handlerType: Handler.Type,
|
||||
file: StaticString = #file,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line) throws {
|
||||
XCTAssertThrowsError(try self.context(handlerType: handlerType).wait(), file: (file), line: line) { error in
|
||||
XCTAssertEqual(.notFound, error as? ChannelPipelineError)
|
||||
|
|
Loading…
Reference in New Issue