Skip to content

Commit d7f2a53

Browse files
authored
Use #fileID/#filePath instead of #file (#1518)
1 parent 3e17f2b commit d7f2a53

21 files changed

+62
-62
lines changed

Sources/Examples/RouteGuide/Client/RouteGuideClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import RouteGuideModel
2323

2424
/// Loads the features from `route_guide_db.json`, assumed to be in the directory above this file.
2525
func loadFeatures() throws -> [Routeguide_Feature] {
26-
let url = URL(fileURLWithPath: #file)
26+
let url = URL(fileURLWithPath: #filePath)
2727
.deletingLastPathComponent() // main.swift
2828
.deletingLastPathComponent() // Client/
2929
.appendingPathComponent("route_guide_db.json")

Sources/Examples/RouteGuide/Server/RouteGuideServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import RouteGuideModel
2424

2525
/// Loads the features from `route_guide_db.json`, assumed to be in the directory above this file.
2626
func loadFeatures() throws -> [Routeguide_Feature] {
27-
let url = URL(fileURLWithPath: #file)
27+
let url = URL(fileURLWithPath: #filePath)
2828
.deletingLastPathComponent() // main.swift
2929
.deletingLastPathComponent() // Server/
3030
.appendingPathComponent("route_guide_db.json")

Sources/GRPC/ConnectionManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ extension ConnectionManager {
10631063
extension ConnectionManager {
10641064
private func invalidState(
10651065
function: StaticString = #function,
1066-
file: StaticString = #file,
1066+
file: StaticString = #fileID,
10671067
line: UInt = #line
10681068
) -> Never {
10691069
preconditionFailure("Invalid state \(self.state) for \(function)", file: file, line: line)

Sources/GRPC/GRPCError.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ extension GRPCError {
309309

310310
init(
311311
_ error: GRPCStatusTransformable,
312-
file: StaticString = #file,
312+
file: StaticString = #fileID,
313313
line: Int = #line,
314314
function: StaticString = #function
315315
) {
@@ -331,7 +331,7 @@ public protocol GRPCErrorProtocol: GRPCStatusTransformable, Equatable, CustomStr
331331
extension GRPCErrorProtocol {
332332
/// Creates a `GRPCError.WithContext` containing a `GRPCError` and the location of the call site.
333333
internal func captureContext(
334-
file: StaticString = #file,
334+
file: StaticString = #fileID,
335335
line: Int = #line,
336336
function: StaticString = #function
337337
) -> GRPCError.WithContext {

Sources/GRPC/GRPCLogger.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal struct GRPCLogger {
4646
internal func trace(
4747
_ message: @autoclosure () -> Logger.Message,
4848
metadata: @autoclosure () -> Logger.Metadata? = nil,
49-
file: String = #file,
49+
file: String = #fileID,
5050
function: String = #function,
5151
line: UInt = #line
5252
) {
@@ -64,7 +64,7 @@ internal struct GRPCLogger {
6464
internal func debug(
6565
_ message: @autoclosure () -> Logger.Message,
6666
metadata: @autoclosure () -> Logger.Metadata? = nil,
67-
file: String = #file,
67+
file: String = #fileID,
6868
function: String = #function,
6969
line: UInt = #line
7070
) {
@@ -82,7 +82,7 @@ internal struct GRPCLogger {
8282
internal func notice(
8383
_ message: @autoclosure () -> Logger.Message,
8484
metadata: @autoclosure () -> Logger.Metadata? = nil,
85-
file: String = #file,
85+
file: String = #fileID,
8686
function: String = #function,
8787
line: UInt = #line
8888
) {
@@ -100,7 +100,7 @@ internal struct GRPCLogger {
100100
internal func warning(
101101
_ message: @autoclosure () -> Logger.Message,
102102
metadata: @autoclosure () -> Logger.Metadata? = nil,
103-
file: String = #file,
103+
file: String = #fileID,
104104
function: String = #function,
105105
line: UInt = #line
106106
) {

Sources/GRPC/PlatformSupport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ extension EventLoopGroup {
416416

417417
internal func preconditionCompatible(
418418
with tlsConfiguration: GRPCTLSConfiguration,
419-
file: StaticString = #file,
419+
file: StaticString = #fileID,
420420
line: UInt = #line
421421
) {
422422
precondition(

Sources/GRPCInteroperabilityTestsImplementation/Assertions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public struct AssertionError: Error {
2828
public func assertEqual<T: Equatable>(
2929
_ value1: T,
3030
_ value2: T,
31-
file: StaticString = #file,
31+
file: StaticString = #fileID,
3232
line: UInt = #line
3333
) throws {
3434
guard value1 == value2 else {
@@ -43,7 +43,7 @@ public func assertEqual<T: Equatable>(
4343
public func waitAndAssertEqual<T: Equatable>(
4444
_ future: EventLoopFuture<T>,
4545
_ value: T,
46-
file: StaticString = #file,
46+
file: StaticString = #fileID,
4747
line: UInt = #line
4848
) throws {
4949
try assertEqual(try future.wait(), value, file: file, line: line)
@@ -56,15 +56,15 @@ public func waitAndAssertEqual<T: Equatable>(
5656
public func waitAndAssertEqual<T: Equatable>(
5757
_ future1: EventLoopFuture<T>,
5858
_ future2: EventLoopFuture<T>,
59-
file: StaticString = #file,
59+
file: StaticString = #fileID,
6060
line: UInt = #line
6161
) throws {
6262
try assertEqual(try future1.wait(), try future2.wait(), file: file, line: line)
6363
}
6464

6565
public func waitAndAssert<T>(
6666
_ future: EventLoopFuture<T>,
67-
file: StaticString = #file,
67+
file: StaticString = #fileID,
6868
line: UInt = #line,
6969
message: String = "",
7070
verify: (T) -> Bool

Tests/GRPCTests/AsyncAwaitSupport/XCTest+AsyncAwait.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import XCTest
2020
internal func XCTAssertThrowsError<T>(
2121
_ expression: @autoclosure () async throws -> T,
2222
verify: (Error) -> Void = { _ in },
23-
file: StaticString = #file,
23+
file: StaticString = #filePath,
2424
line: UInt = #line
2525
) async {
2626
do {

Tests/GRPCTests/ClientTransportTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ClientTransportTests: GRPCTestCase {
8080
self.transport.configure(body)
8181
}
8282

83-
private func connect(file: StaticString = #file, line: UInt = #line) throws {
83+
private func connect(file: StaticString = #filePath, line: UInt = #line) throws {
8484
let address = try assertNoThrow(SocketAddress(unixDomainSocketPath: "/whatever"))
8585
assertThat(
8686
try self.channel.connect(to: address).wait(),
@@ -103,7 +103,7 @@ class ClientTransportTests: GRPCTestCase {
103103

104104
private func sendResponse(
105105
_ part: _GRPCClientResponsePart<String>,
106-
file: StaticString = #file,
106+
file: StaticString = #filePath,
107107
line: UInt = #line
108108
) throws {
109109
assertThat(try self.channel.writeInbound(part), .doesNotThrow(), file: file, line: line)

Tests/GRPCTests/ConnectionManagerTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ConnectionManagerTests: GRPCTestCase {
6666
from: ConnectivityState,
6767
to: ConnectivityState,
6868
timeout: DispatchTimeInterval = .seconds(1),
69-
file: StaticString = #file,
69+
file: StaticString = #filePath,
7070
line: UInt = #line,
7171
body: () throws -> Result
7272
) rethrows -> Result {
@@ -81,7 +81,7 @@ class ConnectionManagerTests: GRPCTestCase {
8181
private func waitForStateChanges<Result>(
8282
_ changes: [Change],
8383
timeout: DispatchTimeInterval = .seconds(1),
84-
file: StaticString = #file,
84+
file: StaticString = #filePath,
8585
line: UInt = #line,
8686
body: () throws -> Result
8787
) rethrows -> Result {
@@ -1248,7 +1248,7 @@ internal class RecordingConnectivityDelegate: ConnectivityStateDelegate {
12481248

12491249
func waitForExpectedChanges(
12501250
timeout: DispatchTimeInterval,
1251-
file: StaticString = #file,
1251+
file: StaticString = #filePath,
12521252
line: UInt = #line
12531253
) {
12541254
let result = self.semaphore.wait(timeout: .now() + timeout)

0 commit comments

Comments
 (0)