remove fullFilePath() hack (#1544)

Motivation:

The fullFilePath() hack doesn't actually work
(https://bugs.swift.org/browse/SR-12934). This is expected behaviour so
currently, the only workaround would be to `#if` whole function bodies
which is a lot of work. Given that in Swift 5.3 `#file` == `#filePath`
still, we can just silence the warning for now.

Modifications:

- Replace `fullFilePath()` by `(#file)`.

Result:

- file locations working properly again.

Co-authored-by: George Barnett <gbarnett@apple.com>
This commit is contained in:
Johannes Weiss 2020-06-05 11:13:09 +01:00 committed by GitHub
parent e57122bd89
commit adeafa9ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 54 additions and 94 deletions

View File

@ -1025,7 +1025,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 = fullFilePath(), line: UInt = #line) {
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = (#file), line: UInt = #line) {
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
let endTime = NIODeadline.now() + time
@ -1053,13 +1053,3 @@ fileprivate class IntHolderWithDeallocationTracking {
_ = self.allDeallocations.add(1)
}
}
#if compiler(>=5.3)
internal func fullFilePath(_ filePath: StaticString = #filePath) -> StaticString {
return filePath
}
#else
internal func fullFilePath(_ filePath: StaticString = #file) -> StaticString {
return filePath
}
#endif

View File

@ -23,7 +23,7 @@ extension ChannelPipeline {
}
func assertDoesNotContain<Handler: ChannelHandler>(handlerType: Handler.Type,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line) throws {
do {
let context = try self.context(handlerType: handlerType).wait()

View File

@ -277,7 +277,7 @@ private final class TestHTTPHandler: ChannelInboundHandler {
}
extension HTTPServerRequestPart {
func assertHead(expectedURI: String, file: StaticString = fullFilePath(), line: UInt = #line) {
func assertHead(expectedURI: String, file: StaticString = (#file), line: UInt = #line) {
switch self {
case .head(let head):
XCTAssertEqual(.GET, head.method)
@ -288,7 +288,7 @@ extension HTTPServerRequestPart {
}
}
func assertBody(expectedMessage: String, file: StaticString = fullFilePath(), line: UInt = #line) {
func assertBody(expectedMessage: String, file: StaticString = (#file), line: UInt = #line) {
switch self {
case .body(let buffer):
// Note that the test server coalesces the body parts for us.
@ -299,7 +299,7 @@ extension HTTPServerRequestPart {
}
}
func assertEnd(file: StaticString = fullFilePath(), line: UInt = #line) {
func assertEnd(file: StaticString = (#file), line: UInt = #line) {
switch self {
case .end(_):
()
@ -339,7 +339,7 @@ func assert(_ condition: @autoclosure () -> Bool,
within time: TimeAmount,
testInterval: TimeAmount? = nil,
_ message: String = "condition not satisfied in time",
file: StaticString = fullFilePath(), line: UInt = #line) {
file: StaticString = (#file), line: UInt = #line) {
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
let endTime = NIODeadline.now() + time
@ -352,13 +352,3 @@ func assert(_ condition: @autoclosure () -> Bool,
XCTFail(message, file: file, line: line)
}
}
#if compiler(>=5.3)
internal func fullFilePath(_ filePath: StaticString = #filePath) -> StaticString {
return filePath
}
#else
internal func fullFilePath(_ filePath: StaticString = #file) -> StaticString {
return filePath
}
#endif

View File

@ -1120,7 +1120,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 = fullFilePath(), line: UInt = #line) {
func testIndexAndLengthFunc<T>(_ body: (Int, Int) -> T?, file: StaticString = (#file), 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)
@ -1131,7 +1131,7 @@ class ByteBufferTest: XCTestCase {
XCTAssertNil(body(Int.min, Int.max), file: file, line: line)
}
func testIndexOrLengthFunc<T>(_ body: (Int) -> T?, file: StaticString = fullFilePath(), line: UInt = #line) {
func testIndexOrLengthFunc<T>(_ body: (Int) -> T?, file: StaticString = (#file), line: UInt = #line) {
XCTAssertNil(body(Int.max))
XCTAssertNil(body(Int.max - 1))
XCTAssertNil(body(Int.min))

View File

@ -17,7 +17,7 @@ import XCTest
class ChannelNotificationTest: XCTestCase {
private static func assertFulfilled(promise: EventLoopPromise<Void>?, promiseName: String, trigger: String, setter: String, file: StaticString = fullFilePath(), line: UInt = #line) {
private static func assertFulfilled(promise: EventLoopPromise<Void>?, promiseName: String, trigger: String, setter: String, file: StaticString = (#file), line: UInt = #line) {
if let promise = promise {
XCTAssertTrue(promise.futureResult.isFulfilled, "\(promiseName) not fulfilled before \(trigger) was called", file: file, line: line)
} else {

View File

@ -255,7 +255,7 @@ public final class ChannelTests: XCTestCase {
expectedFileWritabilities: [(Int, Int)]?,
returns: [IOResult<Int>],
promiseStates: [[Bool]],
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line) throws -> OverallWriteResult {
var everythingState = 0
var singleState = 0
@ -1959,7 +1959,7 @@ public final class ChannelTests: XCTestCase {
}
func testAppropriateAndInappropriateOperationsForUnregisteredSockets() throws {
func checkThatItThrowsInappropriateOperationForState(file: StaticString = fullFilePath(), line: UInt = #line, _ body: () throws -> Void) {
func checkThatItThrowsInappropriateOperationForState(file: StaticString = (#file), line: UInt = #line, _ body: () throws -> Void) {
XCTAssertThrowsError(try body(), file: file, line: line) { error in
XCTAssertEqual(.inappropriateOperationForState, error as? ChannelError)
}
@ -1969,7 +1969,7 @@ public final class ChannelTests: XCTestCase {
XCTAssertNoThrow(try elg.syncShutdownGracefully())
}
func withChannel(skipDatagram: Bool = false, skipStream: Bool = false, skipServerSocket: Bool = false, file: StaticString = fullFilePath(), line: UInt = #line, _ body: (Channel) throws -> Void) {
func withChannel(skipDatagram: Bool = false, skipStream: Bool = false, skipServerSocket: Bool = false, file: StaticString = (#file), 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)]) +

View File

@ -1541,7 +1541,7 @@ public final class MessageToByteEncoderTest: XCTestCase {
try testEncoder(MessageToByteHandler(Int32ToByteEncoderWithDefaultImpl()))
}
private func testEncoder(_ handler: ChannelHandler, file: StaticString = fullFilePath(), line: UInt = #line) throws {
private func testEncoder(_ handler: ChannelHandler, file: StaticString = (#file), line: UInt = #line) throws {
let channel = EmbeddedChannel()
XCTAssertNoThrow(try channel.pipeline.addHandler(MessageToByteHandler(Int32ToByteEncoder())).wait(),

View File

@ -165,7 +165,7 @@ class EmbeddedChannelTest: XCTestCase {
func check<Expected, Actual>(expected: Expected.Type,
actual: Actual.Type,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line) {
do {
_ = try channel.readOutbound(as: Expected.self)

View File

@ -118,7 +118,7 @@ final class MulticastTest: XCTestCase {
}
}
private func assertDatagramReaches(multicastChannel: Channel, sender: Channel, multicastAddress: SocketAddress, file: StaticString = fullFilePath(), line: UInt = #line) throws {
private func assertDatagramReaches(multicastChannel: Channel, sender: Channel, multicastAddress: SocketAddress, file: StaticString = (#file), line: UInt = #line) throws {
let receivedMulticastDatagram = multicastChannel.eventLoop.makePromise(of: AddressedEnvelope<ByteBuffer>.self)
XCTAssertNoThrow(try multicastChannel.pipeline.addHandler(PromiseOnReadHandler(promise: receivedMulticastDatagram)).wait())
@ -140,7 +140,7 @@ final class MulticastTest: XCTestCase {
after timeout: TimeAmount,
sender: Channel,
multicastAddress: SocketAddress,
file: StaticString = fullFilePath(), line: UInt = #line) throws {
file: StaticString = (#file), 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())

View File

@ -102,7 +102,7 @@ class PendingDatagramWritesManagerTests: XCTestCase {
expectedVectorWritabilities: [[(Int, SocketAddress)]]?,
returns: [Result<IOResult<Int>, Error>],
promiseStates: [[Bool]],
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line) throws -> OverallWriteResult {
var everythingState = 0
var singleState = 0

View File

@ -24,7 +24,7 @@ final class SocketOptionProviderTest: XCTestCase {
struct CastError: Error { }
private func convertedChannel(file: StaticString = fullFilePath(), line: UInt = #line) throws -> SocketOptionProvider {
private func convertedChannel(file: StaticString = (#file), 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()
@ -32,7 +32,7 @@ final class SocketOptionProviderTest: XCTestCase {
return provider
}
private func ipv4MulticastProvider(file: StaticString = fullFilePath(), line: UInt = #line) throws -> SocketOptionProvider {
private func ipv4MulticastProvider(file: StaticString = (#file), 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()
@ -40,7 +40,7 @@ final class SocketOptionProviderTest: XCTestCase {
return provider
}
private func ipv6MulticastProvider(file: StaticString = fullFilePath(), line: UInt = #line) throws -> SocketOptionProvider? {
private func ipv6MulticastProvider(file: StaticString = (#file), line: UInt = #line) throws -> SocketOptionProvider? {
guard let ipv6Channel = self.ipv6DatagramChannel else {
return nil
}

View File

@ -836,7 +836,7 @@ final class AccumulateAllReads: ChannelInboundHandler {
}
}
private func assertNoSelectorChanges(fd: CInt, file: StaticString = fullFilePath(), line: UInt = #line) throws {
private func assertNoSelectorChanges(fd: CInt, file: StaticString = (#file), line: UInt = #line) throws {
struct UnexpectedSelectorChanges: Error, CustomStringConvertible {
let description: String
}

View File

@ -49,7 +49,7 @@ final class LockedBox<T> {
init(_ value: T? = nil,
description: String? = nil,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
didSet: @escaping (T?) -> Void = { _ in }) {
self._value = value
@ -346,7 +346,7 @@ class HookedSocket: Socket, UserKernelInterface {
extension HookedSelector {
func assertSyscallAndReturn(_ result: KernelToUser,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
matcher: (UserToKernel) throws -> Bool) throws {
let syscall = try self.userToKernel.takeValue()
@ -358,7 +358,7 @@ extension HookedSelector {
}
}
func assertWakeup(file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertWakeup(file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)")
try self.assertSyscallAndReturn(.returnSelectorEvent(nil), file: file, line: line) { syscall in
if case .whenReady(.block) = syscall {
@ -374,7 +374,7 @@ extension HookedSelector {
extension EventLoop {
internal func runSAL<T>(syscallAssertions: () throws -> Void = {},
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
_ body: @escaping () throws -> T) throws -> T {
let hookedSelector = ((self as! SelectableEventLoop)._selector as! HookedSelector)
@ -458,7 +458,7 @@ extension SALTest {
}
private func makeSocketChannel(eventLoop: SelectableEventLoop,
file: StaticString = fullFilePath(), line: UInt = #line) throws -> SocketChannel {
file: StaticString = (#file), line: UInt = #line) throws -> SocketChannel {
let channel = try eventLoop.runSAL(syscallAssertions: {
try self.assertdisableSIGPIPE(expectedFD: .max, result: .success(()))
try self.assertLocalAddress(address: nil)
@ -497,7 +497,7 @@ extension SALTest {
func makeConnectedSocketChannel(localAddress: SocketAddress?,
remoteAddress: SocketAddress,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line) throws -> SocketChannel {
let channel = try self.makeSocketChannel(eventLoop: self.loop)
let connectFuture = try channel.eventLoop.runSAL(syscallAssertions: {
@ -558,7 +558,7 @@ extension SALTest {
self.wakeups = nil
}
func assertParkedRightNow(file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertParkedRightNow(file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)")
let syscall = try self.userToKernelBox.waitForValue()
if case .whenReady = syscall {
@ -569,7 +569,7 @@ extension SALTest {
}
func assertWaitingForNotification(result: SelectorEvent<NIORegistration>?,
file: StaticString = fullFilePath(), line: UInt = #line) throws {
file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)(result: \(result.debugDescription))")
try self.selector.assertSyscallAndReturn(.returnSelectorEvent(result),
file: file, line: line) { syscall in
@ -581,13 +581,13 @@ extension SALTest {
}
}
func assertWakeup(file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertWakeup(file: StaticString = (#file), line: UInt = #line) throws {
try self.selector.assertWakeup(file: file, line: line)
}
func assertdisableSIGPIPE(expectedFD: CInt,
result: Result<Void, IOError>,
file: StaticString = fullFilePath(), line: UInt = #line) throws {
file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)")
let ret: KernelToUser
switch result {
@ -606,7 +606,7 @@ extension SALTest {
}
func assertLocalAddress(address: SocketAddress?, file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertLocalAddress(address: SocketAddress?, file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)")
try self.selector.assertSyscallAndReturn(address.map { .returnSocketAddress($0) } ??
/* */ .error(.init(errnoCode: EOPNOTSUPP, reason: "nil passed")),
@ -619,7 +619,7 @@ extension SALTest {
}
}
func assertRemoteAddress(address: SocketAddress?, file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertRemoteAddress(address: SocketAddress?, file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)")
try self.selector.assertSyscallAndReturn(address.map { .returnSocketAddress($0) } ??
/* */ .error(.init(errnoCode: EOPNOTSUPP, reason: "nil passed")),
@ -632,7 +632,7 @@ extension SALTest {
}
}
func assertConnect(result: Bool, file: StaticString = fullFilePath(), line: UInt = #line, _ matcher: (SocketAddress) -> Bool = { _ in true }) throws {
func assertConnect(result: Bool, file: StaticString = (#file), 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 {
@ -643,7 +643,7 @@ extension SALTest {
}
}
func assertClose(expectedFD: CInt, file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertClose(expectedFD: CInt, file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)")
try self.selector.assertSyscallAndReturn(.returnVoid, file: file, line: line) { syscall in
if case .close(let fd) = syscall {
@ -656,7 +656,7 @@ extension SALTest {
}
func assertRegister(file: StaticString = fullFilePath(), line: UInt = #line, _ matcher: (Selectable, SelectorEventSet, NIORegistration) throws -> Bool) throws {
func assertRegister(file: StaticString = (#file), 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 {
@ -667,7 +667,7 @@ extension SALTest {
}
}
func assertReregister(file: StaticString = fullFilePath(), line: UInt = #line, _ matcher: (Selectable, SelectorEventSet) throws -> Bool) throws {
func assertReregister(file: StaticString = (#file), 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 {
@ -678,7 +678,7 @@ extension SALTest {
}
}
func assertDeregister(file: StaticString = fullFilePath(), line: UInt = #line, _ matcher: (Selectable) throws -> Bool) throws {
func assertDeregister(file: StaticString = (#file), 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 {
@ -689,7 +689,7 @@ extension SALTest {
}
}
func assertWrite(expectedFD: CInt, expectedBytes: ByteBuffer, return: IOResult<Int>, file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertWrite(expectedFD: CInt, expectedBytes: ByteBuffer, return: IOResult<Int>, file: StaticString = (#file), 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 {
@ -700,7 +700,7 @@ extension SALTest {
}
}
func assertWritev(expectedFD: CInt, expectedBytes: [ByteBuffer], return: IOResult<Int>, file: StaticString = fullFilePath(), line: UInt = #line) throws {
func assertWritev(expectedFD: CInt, expectedBytes: [ByteBuffer], return: IOResult<Int>, file: StaticString = (#file), 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 {
@ -712,7 +712,7 @@ extension SALTest {
}
func assertRead(expectedFD: CInt, expectedBufferSpace: Int, return: ByteBuffer,
file: StaticString = fullFilePath(), line: UInt = #line) throws {
file: StaticString = (#file), line: UInt = #line) throws {
SAL.printIfDebug("\(#function)")
try self.selector.assertSyscallAndReturn(.returnBytes(`return`),
file: file, line: line) { syscall in

View File

@ -244,7 +244,7 @@ func assertSetGetOptionOnOpenAndClosed<Option: ChannelOption>(channel: Channel,
}
}
func assertNoThrowWithValue<T>(_ body: @autoclosure () throws -> T, defaultValue: T? = nil, message: String? = nil, file: StaticString = fullFilePath(), line: UInt = #line) throws -> T {
func assertNoThrowWithValue<T>(_ body: @autoclosure () throws -> T, defaultValue: T? = nil, message: String? = nil, file: StaticString = (#file), line: UInt = #line) throws -> T {
do {
return try body()
} catch {
@ -283,7 +283,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 = fullFilePath(), line: UInt = #line) {
func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testInterval: TimeAmount? = nil, _ message: String = "condition not satisfied in time", file: StaticString = (#file), line: UInt = #line) {
let testInterval = testInterval ?? TimeAmount.nanoseconds(time.nanoseconds / 5)
let endTime = NIODeadline.now() + time
@ -298,15 +298,15 @@ func assert(_ condition: @autoclosure () -> Bool, within time: TimeAmount, testI
}
func getBoolSocketOption(channel: Channel, level: NIOBSDSocket.OptionLevel, name: NIOBSDSocket.Option,
file: StaticString = fullFilePath(), line: UInt = #line) throws -> Bool {
file: StaticString = (#file), 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 = fullFilePath(), line: UInt = #line) {
func assertSuccess<Value>(_ result: Result<Value, Error>, file: StaticString = (#file), 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 = fullFilePath(), line: UInt = #line) {
func assertFailure<Value>(_ result: Result<Value, Error>, file: StaticString = (#file), line: UInt = #line) {
guard case .failure = result else { return XCTFail("Expected result to be a failure", file: file, line: line) }
}
@ -479,7 +479,7 @@ final class FulfillOnFirstEventHandler: ChannelDuplexHandler {
}
}
func forEachActiveChannelType<T>(file: StaticString = fullFilePath(),
func forEachActiveChannelType<T>(file: StaticString = (#file),
line: UInt = #line,
_ body: @escaping (Channel) throws -> T) throws -> [T] {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
@ -519,7 +519,7 @@ func forEachActiveChannelType<T>(file: StaticString = fullFilePath(),
func withTCPServerChannel<R>(bindTarget: SocketAddress? = nil,
group: EventLoopGroup,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
_ body: (Channel) throws -> R) throws -> R {
let server = try ServerBootstrap(group: group)
@ -538,7 +538,7 @@ func withTCPServerChannel<R>(bindTarget: SocketAddress? = nil,
func withCrossConnectedSockAddrChannels<R>(bindTarget: SocketAddress,
forceSeparateEventLoops: Bool = false,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
_ body: (Channel, Channel) throws -> R) throws -> R {
let serverGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
@ -588,7 +588,7 @@ func withCrossConnectedSockAddrChannels<R>(bindTarget: SocketAddress,
}
func withCrossConnectedTCPChannels<R>(forceSeparateEventLoops: Bool = false,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
_ body: (Channel, Channel) throws -> R) throws -> R {
return try withCrossConnectedSockAddrChannels(bindTarget: .init(ipAddress: "127.0.0.1", port: 0),
@ -597,7 +597,7 @@ func withCrossConnectedTCPChannels<R>(forceSeparateEventLoops: Bool = false,
}
func withCrossConnectedUnixDomainSocketChannels<R>(forceSeparateEventLoops: Bool = false,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
_ body: (Channel, Channel) throws -> R) throws -> R {
return try withTemporaryDirectory { tempDir in
@ -609,7 +609,7 @@ func withCrossConnectedUnixDomainSocketChannels<R>(forceSeparateEventLoops: Bool
}
func withCrossConnectedPipeChannels<R>(forceSeparateEventLoops: Bool = false,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
_ body: (Channel, Channel) throws -> R) throws -> R {
let channel1Group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
@ -664,7 +664,7 @@ func withCrossConnectedPipeChannels<R>(forceSeparateEventLoops: Bool = false,
}
func forEachCrossConnectedStreamChannelPair<R>(forceSeparateEventLoops: Bool = false,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line,
_ body: (Channel, Channel) throws -> R) throws -> [R] {
let r1 = try withCrossConnectedTCPChannels(forceSeparateEventLoops: forceSeparateEventLoops, body)
@ -701,13 +701,3 @@ extension EventLoopFuture {
}
}
}
#if compiler(>=5.3)
internal func fullFilePath(_ filePath: StaticString = #filePath) -> StaticString {
return filePath
}
#else
internal func fullFilePath(_ filePath: StaticString = #file) -> StaticString {
return filePath
}
#endif

View File

@ -32,7 +32,7 @@ extension EmbeddedChannel {
extension ChannelPipeline {
fileprivate func assertDoesNotContain<Handler: ChannelHandler>(handlerType: Handler.Type,
file: StaticString = fullFilePath(),
file: StaticString = (#file),
line: UInt = #line) throws {
XCTAssertThrowsError(try self.context(handlerType: handlerType).wait(), file: file, line: line) { error in
XCTAssertEqual(.notFound, error as? ChannelPipelineError)
@ -403,13 +403,3 @@ class WebSocketClientEndToEndTests: XCTestCase {
XCTAssertNoThrow(try clientChannel.close().wait())
}
}
#if compiler(>=5.3)
internal func fullFilePath(_ filePath: StaticString = #filePath) -> StaticString {
return filePath
}
#else
internal func fullFilePath(_ filePath: StaticString = #file) -> StaticString {
return filePath
}
#endif