Skip to content

Commit acb1838

Browse files
authored
Swift 6 prep - Part 1 (#106)
### Motivation Fixes to get closer to building in Swift 6 mode without diagnostics. ### Modifications - Made two public types Sendable - s/#file/#filePath in tests ### Result Builds with fewer warnings when trying Swift 6 mode (will open another PR for the remaining work). ### Test Plan Unit tests passed.
1 parent 9a8291f commit acb1838

10 files changed

+37
-23
lines changed

Sources/OpenAPIRuntime/Base/OpenAPIMIMEType.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
import Foundation
1515

1616
/// A container for a parsed, valid MIME type.
17-
@_spi(Generated) public struct OpenAPIMIMEType: Equatable {
17+
@_spi(Generated) public struct OpenAPIMIMEType: Equatable, Sendable {
1818

1919
/// XML MIME type
2020
public static let xml: OpenAPIMIMEType = .init(kind: .concrete(type: "application", subtype: "xml"))
2121

2222
/// The kind of the MIME type.
23-
public enum Kind: Equatable {
23+
public enum Kind: Equatable, Sendable {
2424

2525
/// Any, spelled as `*/*`.
2626
case any

Tests/OpenAPIRuntimeTests/Base/Test_ContentDisposition.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class Test_ContentDisposition: Test_Runtime {
2121
input: String,
2222
parsed: ContentDisposition?,
2323
output: String?,
24-
file: StaticString = #file,
24+
file: StaticString = #filePath,
2525
line: UInt = #line
2626
) {
2727
let value = ContentDisposition(rawValue: input)

Tests/OpenAPIRuntimeTests/Base/Test_OpenAPIMIMEType.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ final class Test_OpenAPIMIMEType: Test_Runtime {
8888
receivedParameters: [String: String],
8989
against option: OpenAPIMIMEType,
9090
expected expectedMatch: OpenAPIMIMEType.Match,
91-
file: StaticString = #file,
91+
file: StaticString = #filePath,
9292
line: UInt = #line
9393
) {
9494
let result = OpenAPIMIMEType.evaluate(
@@ -109,7 +109,7 @@ final class Test_OpenAPIMIMEType: Test_Runtime {
109109
func testJSONWith2Params(
110110
against option: OpenAPIMIMEType,
111111
expected expectedMatch: OpenAPIMIMEType.Match,
112-
file: StaticString = #file,
112+
file: StaticString = #filePath,
113113
line: UInt = #line
114114
) {
115115
testCase(

Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Common.swift

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class Test_CommonConverterExtensions: Test_Runtime {
2626
received: String?,
2727
options: [String],
2828
expected expectedChoice: String,
29-
file: StaticString = #file,
29+
file: StaticString = #filePath,
3030
line: UInt = #line
3131
) throws {
3232
let choice = try converter.bestContentType(received: received.map { .init($0)! }, options: options)
@@ -109,9 +109,13 @@ final class Test_CommonConverterExtensions: Test_Runtime {
109109
}
110110

111111
func testExtractContentDispositionNameAndFilename() throws {
112-
func testCase(value: String?, name: String?, filename: String?, file: StaticString = #file, line: UInt = #line)
113-
throws
114-
{
112+
func testCase(
113+
value: String?,
114+
name: String?,
115+
filename: String?,
116+
file: StaticString = #filePath,
117+
line: UInt = #line
118+
) throws {
115119
let headerFields: HTTPFields
116120
if let value { headerFields = [.contentDisposition: value] } else { headerFields = [:] }
117121
let (actualName, actualFilename) = try converter.extractContentDispositionNameAndFilename(in: headerFields)

Tests/OpenAPIRuntimeTests/EventStreams/Test_ServerSentEventsDecoding.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import XCTest
1616
import Foundation
1717

1818
final class Test_ServerSentEventsDecoding: Test_Runtime {
19-
func _test(input: String, output: [ServerSentEvent], file: StaticString = #file, line: UInt = #line) async throws {
19+
func _test(input: String, output: [ServerSentEvent], file: StaticString = #filePath, line: UInt = #line)
20+
async throws
21+
{
2022
let sequence = asOneBytePerElementSequence(ArraySlice(input.utf8)).asDecodedServerSentEvents()
2123
let events = try await [ServerSentEvent](collecting: sequence)
2224
XCTAssertEqual(events.count, output.count, file: file, line: line)
@@ -85,7 +87,7 @@ final class Test_ServerSentEventsDecoding: Test_Runtime {
8587
func _testJSONData<JSONType: Decodable & Hashable & Sendable>(
8688
input: String,
8789
output: [ServerSentEventWithJSONData<JSONType>],
88-
file: StaticString = #file,
90+
file: StaticString = #filePath,
8991
line: UInt = #line
9092
) async throws {
9193
let sequence = asOneBytePerElementSequence(ArraySlice(input.utf8))
@@ -123,7 +125,7 @@ final class Test_ServerSentEventsDecoding: Test_Runtime {
123125
}
124126

125127
final class Test_ServerSentEventsDecoding_Lines: Test_Runtime {
126-
func _test(input: String, output: [String], file: StaticString = #file, line: UInt = #line) async throws {
128+
func _test(input: String, output: [String], file: StaticString = #filePath, line: UInt = #line) async throws {
127129
let upstream = asOneBytePerElementSequence(ArraySlice(input.utf8))
128130
let sequence = ServerSentEventsLineDeserializationSequence(upstream: upstream)
129131
let lines = try await [ArraySlice<UInt8>](collecting: sequence)

Tests/OpenAPIRuntimeTests/EventStreams/Test_ServerSentEventsEncoding.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import XCTest
1616
import Foundation
1717

1818
final class Test_ServerSentEventsEncoding: Test_Runtime {
19-
func _test(input: [ServerSentEvent], output: String, file: StaticString = #file, line: UInt = #line) async throws {
19+
func _test(input: [ServerSentEvent], output: String, file: StaticString = #filePath, line: UInt = #line)
20+
async throws
21+
{
2022
let sequence = WrappedSyncSequence(sequence: input).asEncodedServerSentEvents()
2123
try await XCTAssertEqualAsyncData(sequence, output.utf8, file: file, line: line)
2224
}
@@ -73,7 +75,7 @@ final class Test_ServerSentEventsEncoding: Test_Runtime {
7375
func _testJSONData<JSONType: Encodable & Hashable & Sendable>(
7476
input: [ServerSentEventWithJSONData<JSONType>],
7577
output: String,
76-
file: StaticString = #file,
78+
file: StaticString = #filePath,
7779
line: UInt = #line
7880
) async throws {
7981
let sequence = WrappedSyncSequence(sequence: input).asEncodedServerSentEventsWithJSONData()

Tests/OpenAPIRuntimeTests/Interface/Test_HTTPBody.swift

+12-6
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,22 @@ final class Test_Body: Test_Runtime {
229229
}
230230

231231
extension Test_Body {
232-
func _testConsume(_ body: HTTPBody, expected: HTTPBody.ByteChunk, file: StaticString = #file, line: UInt = #line)
233-
async throws
234-
{
232+
func _testConsume(
233+
_ body: HTTPBody,
234+
expected: HTTPBody.ByteChunk,
235+
file: StaticString = #filePath,
236+
line: UInt = #line
237+
) async throws {
235238
let output = try await ArraySlice(collecting: body, upTo: .max)
236239
XCTAssertEqual(output, expected, file: file, line: line)
237240
}
238241

239-
func _testConsume(_ body: HTTPBody, expected: some StringProtocol, file: StaticString = #file, line: UInt = #line)
240-
async throws
241-
{
242+
func _testConsume(
243+
_ body: HTTPBody,
244+
expected: some StringProtocol,
245+
file: StaticString = #filePath,
246+
line: UInt = #line
247+
) async throws {
242248
let output = try await String(collecting: body, upTo: .max)
243249
XCTAssertEqual(output, expected.description, file: file, line: line)
244250
}

Tests/OpenAPIRuntimeTests/Test_Runtime.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ struct MockCustomCoder: CustomCoder {
237237
/// - rhs: The expected absolute string representation.
238238
/// - file: The file name to include in the failure message (default is the source file where this function is called).
239239
/// - line: The line number to include in the failure message (default is the line where this function is called).
240-
public func XCTAssertEqualURLString(_ lhs: URL?, _ rhs: String, file: StaticString = #file, line: UInt = #line) {
240+
public func XCTAssertEqualURLString(_ lhs: URL?, _ rhs: String, file: StaticString = #filePath, line: UInt = #line) {
241241
guard let lhs else {
242242
XCTFail("URL is nil")
243243
return

Tests/OpenAPIRuntimeTests/URICoder/Decoder/Test_URIValueFromNodeDecoder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ final class Test_URIValueFromNodeDecoder: Test_Runtime {
8181
key: String,
8282
style: URICoderConfiguration.Style = .form,
8383
explode: Bool = true,
84-
file: StaticString = #file,
84+
file: StaticString = #filePath,
8585
line: UInt = #line
8686
) throws {
8787
let decoder = URIValueFromNodeDecoder(

Tests/OpenAPIRuntimeTests/URICoder/Test_URICodingRoundtrip.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ final class Test_URICodingRoundtrip: Test_Runtime {
418418
_ value: T,
419419
key: String,
420420
_ variants: Variants<T>,
421-
file: StaticString = #file,
421+
file: StaticString = #filePath,
422422
line: UInt = #line
423423
) throws {
424424
func testVariant(name: String, configuration: URICoderConfiguration, variant: Variants<T>.Input) throws {

0 commit comments

Comments
 (0)