Browse Source

Revert #782 and suppress warnings (#825)

Motivation:

- #782 doesn't work as expected

Modifications:

- Revert #782
- Wrap (#file) in parentheses

Result:

File locations work again
George Barnett 5 years ago
parent
commit
6cea0c8791

+ 2 - 2
Tests/GRPCTests/EventLoopFuture+Assertions.swift

@@ -24,7 +24,7 @@ extension EventLoopFuture where Value: Equatable {
   /// - Parameters:
   ///   - expected: The expected value.
   ///   - expectation: A test expectation to fulfill once the future has completed.
-  func assertEqual(_ expected: Value, fulfill expectation: XCTestExpectation, file: StaticString = magicFile(), line: UInt = #line) {
+  func assertEqual(_ expected: Value, fulfill expectation: XCTestExpectation, file: StaticString = (#file), line: UInt = #line) {
     self.whenComplete { result in
       defer {
         expectation.fulfill()
@@ -50,7 +50,7 @@ extension EventLoopFuture {
   /// - Parameters:
   ///   - expectation: A test expectation to fulfill once the future has completed.
   ///   - handler: A block to run additional verification on the error. Defaults to no-op.
-  func assertError(fulfill expectation: XCTestExpectation, file: StaticString = magicFile(), line: UInt = #line, handler: @escaping (Error) -> Void = { _ in }) {
+  func assertError(fulfill expectation: XCTestExpectation, file: StaticString = (#file), line: UInt = #line, handler: @escaping (Error) -> Void = { _ in }) {
     self.whenComplete { result in
       defer {
         expectation.fulfill()

+ 0 - 31
Tests/GRPCTests/MagicFile.swift

@@ -1,31 +0,0 @@
-/*
- * Copyright 2020, gRPC Authors All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// SE-0274 renames #file to #filePath so that #file may refer to the name of a file instead of
-// its path. From Swift 5.3+ XCTAssert* accepts #filePath and warns when a #file is passed to it.
-// These functions are used to work around that.
-//
-// https://github.com/apple/swift-evolution/blob/master/proposals/0274-magic-file.md
-
-#if swift(>=5.3)
-func magicFile(file: StaticString = #filePath) -> StaticString {
-    return file
-}
-#else
-func magicFile(file: StaticString = #file) -> StaticString {
-    return file
-}
-#endif

+ 1 - 1
Tests/GRPCTests/SampleCertificate+Assertions.swift

@@ -18,7 +18,7 @@ import XCTest
 import GRPCSampleData
 
 extension SampleCertificate {
-  func assertNotExpired(file: StaticString = magicFile(), line: UInt = #line) {
+  func assertNotExpired(file: StaticString = (#file), line: UInt = #line) {
     XCTAssertFalse(self.isExpired, "Certificate expired at \(self.notAfter)", file: file, line: line)
   }
 }