From 2af359fd7d98d96e599c0990ff3b073e6ab77bb2 Mon Sep 17 00:00:00 2001 From: tanner0101 Date: Tue, 23 Jun 2020 13:56:05 -0400 Subject: [PATCH 1/2] update for xcode 12 --- Sources/Development/routes.swift | 2 +- Sources/Vapor/Utilities/Base32.swift | 4 ++-- Sources/XCTVapor/XCTApplication.swift | 2 +- Sources/XCTVapor/XCTHTTPResponse.swift | 6 +++--- Tests/VaporTests/ErrorTests.swift | 2 +- Tests/VaporTests/PasswordTests.swift | 4 ++-- Tests/VaporTests/ValidationTests.swift | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Sources/Development/routes.swift b/Sources/Development/routes.swift index b7f197d808..24a1ca2d6e 100644 --- a/Sources/Development/routes.swift +++ b/Sources/Development/routes.swift @@ -89,7 +89,7 @@ public func routes(_ app: Application) throws { guard let running = req.application.running else { throw Abort(.internalServerError) } - _ = running.stop() + running.stop() return .ok } diff --git a/Sources/Vapor/Utilities/Base32.swift b/Sources/Vapor/Utilities/Base32.swift index 9e73592932..8956c6faf4 100644 --- a/Sources/Vapor/Utilities/Base32.swift +++ b/Sources/Vapor/Utilities/Base32.swift @@ -14,7 +14,7 @@ extension Data { /// Decodes base32 encoded `Data`. public init?(base32Encoded: Data) { let maxSize = (base32Encoded.count * 5 + 4) / 8 - var result = UnsafeMutablePointer.allocate(capacity: maxSize) + let result = UnsafeMutablePointer.allocate(capacity: maxSize) defer { result.deinitialize(count: maxSize) result.deallocate() @@ -37,7 +37,7 @@ extension Data { /// - returns: The base32 encoded data. public func base32EncodedData() -> Data { let maxSize = (count * 8 + 4) / 5 - var result = UnsafeMutablePointer.allocate(capacity: maxSize) + let result = UnsafeMutablePointer.allocate(capacity: maxSize) defer { result.deinitialize(count: maxSize) result.deallocate() diff --git a/Sources/XCTVapor/XCTApplication.swift b/Sources/XCTVapor/XCTApplication.swift index 70259c05fa..d8583743cb 100644 --- a/Sources/XCTVapor/XCTApplication.swift +++ b/Sources/XCTVapor/XCTApplication.swift @@ -104,7 +104,7 @@ extension XCTApplicationTester { _ path: String, headers: HTTPHeaders = [:], body: ByteBuffer? = nil, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line, beforeRequest: (inout XCTHTTPRequest) throws -> () = { _ in }, afterResponse: (XCTHTTPResponse) throws -> () = { _ in } diff --git a/Sources/XCTVapor/XCTHTTPResponse.swift b/Sources/XCTVapor/XCTHTTPResponse.swift index ef97187f62..37f80c3eea 100644 --- a/Sources/XCTVapor/XCTHTTPResponse.swift +++ b/Sources/XCTVapor/XCTHTTPResponse.swift @@ -42,7 +42,7 @@ extension Response.Body { public func XCTAssertContent( _ type: D.Type, _ res: XCTHTTPResponse, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line, _ closure: (D) -> () ) @@ -61,7 +61,7 @@ public func XCTAssertContent( } } -public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: StaticString = #file, line: UInt = #line) { +public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: StaticString = #filePath, line: UInt = #line) { switch (haystack, needle) { case (.some(let haystack), .some(let needle)): XCTAssert(haystack.contains(needle), "\(haystack) does not contain \(needle)", file: file, line: line) @@ -74,7 +74,7 @@ public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: Stat } } -public func XCTAssertEqualJSON(_ data: String?, _ test: T, file: StaticString = #file, line: UInt = #line) +public func XCTAssertEqualJSON(_ data: String?, _ test: T, file: StaticString = #filePath, line: UInt = #line) where T: Codable & Equatable { guard let data = data else { diff --git a/Tests/VaporTests/ErrorTests.swift b/Tests/VaporTests/ErrorTests.swift index ef08b3cdc8..5769d848f6 100644 --- a/Tests/VaporTests/ErrorTests.swift +++ b/Tests/VaporTests/ErrorTests.swift @@ -154,7 +154,7 @@ final class ErrorTests: XCTestCase { func XCTAssertContains( _ haystack: String?, _ needle: String, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) { guard let haystack = haystack else { diff --git a/Tests/VaporTests/PasswordTests.swift b/Tests/VaporTests/PasswordTests.swift index 10ffc4fe88..6828d26b94 100644 --- a/Tests/VaporTests/PasswordTests.swift +++ b/Tests/VaporTests/PasswordTests.swift @@ -82,7 +82,7 @@ final class PasswordTests: XCTestCase { private func assertAsyncApplicationPasswordVerifies( _ provider: Application.Passwords.Provider, on app: Application, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) throws { app.passwords.use(provider) @@ -103,7 +103,7 @@ final class PasswordTests: XCTestCase { private func assertAsyncRequestPasswordVerifies( _ provider: Application.Passwords.Provider, on app: Application, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) throws { app.passwords.use(provider) diff --git a/Tests/VaporTests/ValidationTests.swift b/Tests/VaporTests/ValidationTests.swift index 03838965fa..7faf4efbe8 100644 --- a/Tests/VaporTests/ValidationTests.swift +++ b/Tests/VaporTests/ValidationTests.swift @@ -281,7 +281,7 @@ private func assert( _ data: T, fails validator: Validator, _ description: String, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) { let result = validator.validate(data) @@ -292,7 +292,7 @@ private func assert( private func assert( _ data: T, passes validator: Validator, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) { let result = validator.validate(data) From aec5927b2495553d79fd5fad7da1a4dba39145c8 Mon Sep 17 00:00:00 2001 From: tanner0101 Date: Tue, 23 Jun 2020 14:16:55 -0400 Subject: [PATCH 2/2] use (#file) instead --- Sources/XCTVapor/XCTApplication.swift | 2 +- Sources/XCTVapor/XCTHTTPResponse.swift | 6 +++--- Tests/VaporTests/ErrorTests.swift | 2 +- Tests/VaporTests/PasswordTests.swift | 4 ++-- Tests/VaporTests/ValidationTests.swift | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/XCTVapor/XCTApplication.swift b/Sources/XCTVapor/XCTApplication.swift index d8583743cb..0559ed2ff7 100644 --- a/Sources/XCTVapor/XCTApplication.swift +++ b/Sources/XCTVapor/XCTApplication.swift @@ -104,7 +104,7 @@ extension XCTApplicationTester { _ path: String, headers: HTTPHeaders = [:], body: ByteBuffer? = nil, - file: StaticString = #filePath, + file: StaticString = (#file), line: UInt = #line, beforeRequest: (inout XCTHTTPRequest) throws -> () = { _ in }, afterResponse: (XCTHTTPResponse) throws -> () = { _ in } diff --git a/Sources/XCTVapor/XCTHTTPResponse.swift b/Sources/XCTVapor/XCTHTTPResponse.swift index 37f80c3eea..6eec82748c 100644 --- a/Sources/XCTVapor/XCTHTTPResponse.swift +++ b/Sources/XCTVapor/XCTHTTPResponse.swift @@ -42,7 +42,7 @@ extension Response.Body { public func XCTAssertContent( _ type: D.Type, _ res: XCTHTTPResponse, - file: StaticString = #filePath, + file: StaticString = (#file), line: UInt = #line, _ closure: (D) -> () ) @@ -61,7 +61,7 @@ public func XCTAssertContent( } } -public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: StaticString = #filePath, line: UInt = #line) { +public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: StaticString = (#file), line: UInt = #line) { switch (haystack, needle) { case (.some(let haystack), .some(let needle)): XCTAssert(haystack.contains(needle), "\(haystack) does not contain \(needle)", file: file, line: line) @@ -74,7 +74,7 @@ public func XCTAssertContains(_ haystack: String?, _ needle: String?, file: Stat } } -public func XCTAssertEqualJSON(_ data: String?, _ test: T, file: StaticString = #filePath, line: UInt = #line) +public func XCTAssertEqualJSON(_ data: String?, _ test: T, file: StaticString = (#file), line: UInt = #line) where T: Codable & Equatable { guard let data = data else { diff --git a/Tests/VaporTests/ErrorTests.swift b/Tests/VaporTests/ErrorTests.swift index 5769d848f6..5b7e89b826 100644 --- a/Tests/VaporTests/ErrorTests.swift +++ b/Tests/VaporTests/ErrorTests.swift @@ -154,7 +154,7 @@ final class ErrorTests: XCTestCase { func XCTAssertContains( _ haystack: String?, _ needle: String, - file: StaticString = #filePath, + file: StaticString = (#file), line: UInt = #line ) { guard let haystack = haystack else { diff --git a/Tests/VaporTests/PasswordTests.swift b/Tests/VaporTests/PasswordTests.swift index 6828d26b94..6bb65424a0 100644 --- a/Tests/VaporTests/PasswordTests.swift +++ b/Tests/VaporTests/PasswordTests.swift @@ -82,7 +82,7 @@ final class PasswordTests: XCTestCase { private func assertAsyncApplicationPasswordVerifies( _ provider: Application.Passwords.Provider, on app: Application, - file: StaticString = #filePath, + file: StaticString = (#file), line: UInt = #line ) throws { app.passwords.use(provider) @@ -103,7 +103,7 @@ final class PasswordTests: XCTestCase { private func assertAsyncRequestPasswordVerifies( _ provider: Application.Passwords.Provider, on app: Application, - file: StaticString = #filePath, + file: StaticString = (#file), line: UInt = #line ) throws { app.passwords.use(provider) diff --git a/Tests/VaporTests/ValidationTests.swift b/Tests/VaporTests/ValidationTests.swift index 7faf4efbe8..b8239fb28a 100644 --- a/Tests/VaporTests/ValidationTests.swift +++ b/Tests/VaporTests/ValidationTests.swift @@ -281,7 +281,7 @@ private func assert( _ data: T, fails validator: Validator, _ description: String, - file: StaticString = #filePath, + file: StaticString = (#file), line: UInt = #line ) { let result = validator.validate(data) @@ -292,7 +292,7 @@ private func assert( private func assert( _ data: T, passes validator: Validator, - file: StaticString = #filePath, + file: StaticString = (#file), line: UInt = #line ) { let result = validator.validate(data)