Skip to content

Commit 9878ef5

Browse files
committed
Make LanguageServerProtocolJSONRPCTests build in Swift 6 mode
1 parent 10e6839 commit 9878ef5

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

Tests/LanguageServerProtocolJSONRPCTests/CodingTests.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,8 @@ final class CodingTests: XCTestCase {
283283
return $0 == .string("unknown") ? nil : InitializeResult.self
284284
}
285285

286-
let info = defaultCodingInfo.merging([CodingUserInfoKey.responseTypeCallbackKey: responseTypeCallback]) {
287-
(_, new) in new
288-
}
286+
var info = defaultCodingInfo as [CodingUserInfoKey: Any]
287+
info[CodingUserInfoKey.responseTypeCallbackKey] = responseTypeCallback
289288

290289
checkMessageDecodingError(
291290
MessageDecodingError.invalidRequest(
@@ -367,7 +366,7 @@ final class CodingTests: XCTestCase {
367366
}
368367
}
369368

370-
let defaultCodingInfo: [CodingUserInfoKey: Any] = [CodingUserInfoKey.messageRegistryKey: MessageRegistry.lspProtocol]
369+
let defaultCodingInfo = [CodingUserInfoKey.messageRegistryKey: MessageRegistry.lspProtocol]
371370

372371
private func checkMessageCoding<Request: RequestType & Equatable>(
373372
_ value: Request,
@@ -418,7 +417,7 @@ private func checkMessageCoding<Response: ResponseType & Equatable>(
418417
return $0 == .string("unknown") ? nil : Response.self
419418
}
420419

421-
var codingInfo = defaultCodingInfo
420+
var codingInfo = defaultCodingInfo as [CodingUserInfoKey: Any]
422421
codingInfo[.responseTypeCallbackKey] = callback
423422

424423
checkCoding(JSONRPCMessage.response(value, id: id), json: json, userInfo: codingInfo, file: file, line: line) {

Tests/LanguageServerProtocolJSONRPCTests/ConnectionPerfTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ConnectionPerfTests: PerfTestCase {
3636
expectation.fulfill()
3737
}
3838

39-
waitForExpectations(timeout: defaultTimeout)
39+
wait(for: [expectation], timeout: defaultTimeout)
4040
}
4141
}
4242

Tests/LanguageServerProtocolJSONRPCTests/ConnectionTests.swift

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConnectionTests: XCTestCase {
3737
XCTAssertEqual("a/b", dec.string)
3838
}
3939

40-
func testEcho() {
40+
func testEcho() async throws {
4141
let client = connection.client
4242
let expectation = self.expectation(description: "response received")
4343

@@ -48,7 +48,7 @@ class ConnectionTests: XCTestCase {
4848
expectation.fulfill()
4949
}
5050

51-
waitForExpectations(timeout: defaultTimeout)
51+
try await fulfillmentOfOrThrow([expectation])
5252
}
5353

5454
func testMessageBuffer() async throws {
@@ -95,7 +95,7 @@ class ConnectionTests: XCTestCase {
9595
XCTAssert(connection.serverToClientConnection.requestBufferIsEmpty)
9696
}
9797

98-
func testEchoError() {
98+
func testEchoError() async throws {
9999
let client = connection.client
100100
let expectation = self.expectation(description: "response received 1")
101101
let expectation2 = self.expectation(description: "response received 2")
@@ -114,7 +114,7 @@ class ConnectionTests: XCTestCase {
114114
expectation2.fulfill()
115115
}
116116

117-
waitForExpectations(timeout: defaultTimeout)
117+
try await fulfillmentOfOrThrow([expectation, expectation2])
118118
}
119119

120120
func testEchoNote() async throws {
@@ -131,7 +131,7 @@ class ConnectionTests: XCTestCase {
131131
try await fulfillmentOfOrThrow([expectation])
132132
}
133133

134-
func testUnknownRequest() {
134+
func testUnknownRequest() async throws {
135135
let client = connection.client
136136
let expectation = self.expectation(description: "response received")
137137

@@ -145,10 +145,10 @@ class ConnectionTests: XCTestCase {
145145
expectation.fulfill()
146146
}
147147

148-
waitForExpectations(timeout: defaultTimeout)
148+
try await fulfillmentOfOrThrow([expectation])
149149
}
150150

151-
func testUnknownNotification() {
151+
func testUnknownNotification() async throws {
152152
let client = connection.client
153153
let expectation = self.expectation(description: "note received")
154154

@@ -167,10 +167,10 @@ class ConnectionTests: XCTestCase {
167167
expectation.fulfill()
168168
}
169169

170-
waitForExpectations(timeout: defaultTimeout)
170+
try await fulfillmentOfOrThrow([expectation])
171171
}
172172

173-
func testUnexpectedResponse() {
173+
func testUnexpectedResponse() async throws {
174174
let client = connection.client
175175
let expectation = self.expectation(description: "response received")
176176

@@ -186,10 +186,10 @@ class ConnectionTests: XCTestCase {
186186
expectation.fulfill()
187187
}
188188

189-
waitForExpectations(timeout: defaultTimeout)
189+
try await fulfillmentOfOrThrow([expectation])
190190
}
191191

192-
func testSendAfterClose() {
192+
func testSendAfterClose() async throws {
193193
let client = connection.client
194194
let expectation = self.expectation(description: "note received")
195195

@@ -206,7 +206,7 @@ class ConnectionTests: XCTestCase {
206206
connection.clientToServerConnection.close()
207207
connection.clientToServerConnection.close()
208208

209-
waitForExpectations(timeout: defaultTimeout)
209+
try await fulfillmentOfOrThrow([expectation])
210210
}
211211

212212
func testSendBeforeClose() async throws {
@@ -229,7 +229,7 @@ class ConnectionTests: XCTestCase {
229229
/// DispatchIO can make its callback at any time, so this test is to try to
230230
/// provoke a race between those things and ensure the closeHandler is called
231231
/// exactly once.
232-
func testCloseRace() {
232+
func testCloseRace() async throws {
233233
for _ in 0...100 {
234234
let to = Pipe()
235235
let from = Pipe()
@@ -274,9 +274,8 @@ class ConnectionTests: XCTestCase {
274274
#endif
275275
conn.close()
276276

277-
withExtendedLifetime(conn) {
278-
waitForExpectations(timeout: defaultTimeout)
279-
}
277+
try await fulfillmentOfOrThrow([expectation])
278+
withExtendedLifetime(conn) {}
280279
}
281280
}
282281

0 commit comments

Comments
 (0)