Skip to content

Commit 3ea2b64

Browse files
committed
convert tests from #file to using #filePath
1 parent c49849b commit 3ea2b64

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

Sources/LSPTestSupport/CheckCoding.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import XCTest
1717
///
1818
/// - parameter value: The value to encode/decode.
1919
/// - parameter json: The expected json encoding.
20-
public func checkCoding<T>(_ value: T, json: String, file: StaticString = #file, line: UInt = #line) where T: Codable & Equatable {
20+
public func checkCoding<T>(_ value: T, json: String, file: StaticString = #filePath, line: UInt = #line) where T: Codable & Equatable {
2121
let encoder = JSONEncoder()
2222
encoder.outputFormatting.insert(.prettyPrinted)
2323
if #available(macOS 10.13, *) {
@@ -57,7 +57,7 @@ private struct WrapFragment<T>: Equatable, Codable where T: Equatable & Codable
5757
///
5858
/// - parameter value: The value to encode/decode.
5959
/// - parameter json: The expected json encoding.
60-
public func checkDecoding<T>(json: String, expected value: T, file: StaticString = #file, line: UInt = #line) where T: Codable & Equatable {
60+
public func checkDecoding<T>(json: String, expected value: T, file: StaticString = #filePath, line: UInt = #line) where T: Codable & Equatable {
6161

6262
let wrappedStr = "{\"value\":\(json)}"
6363
let data = wrappedStr.data(using: .utf8)!
@@ -67,7 +67,7 @@ public func checkDecoding<T>(json: String, expected value: T, file: StaticString
6767
XCTAssertEqual(value, decodedValue, file: file, line: line)
6868
}
6969

70-
public func checkCoding<T>(_ value: T, json: String, userInfo: [CodingUserInfoKey: Any] = [:], file: StaticString = #file, line: UInt = #line, body: (T) -> Void) where T: Codable {
70+
public func checkCoding<T>(_ value: T, json: String, userInfo: [CodingUserInfoKey: Any] = [:], file: StaticString = #filePath, line: UInt = #line, body: (T) -> Void) where T: Codable {
7171
let encoder = JSONEncoder()
7272
encoder.outputFormatting.insert(.prettyPrinted)
7373
if #available(macOS 10.13, *) {

Tests/LSPLoggingTests/SupportTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ final class SupportTests: XCTestCase {
2525

2626
func check(expected: [(String, LogLevel)], file: StaticString = #file, line: UInt = #line) {
2727
testLogger.flush()
28-
XCTAssert(messages.count == expected.count, "\(messages) does not match expected \(expected)", file: file, line: line)
29-
XCTAssert(zip(messages, expected).allSatisfy({ $0.0 == $0.1 }), "\(messages) does not match expected \(expected)", file: file, line: line)
28+
XCTAssert(messages.count == expected.count, "\(messages) does not match expected \(expected)", file: (file), line: line)
29+
XCTAssert(zip(messages, expected).allSatisfy({ $0.0 == $0.1 }), "\(messages) does not match expected \(expected)", file: (file), line: line)
3030
messages.removeAll()
3131
}
3232

Tests/LanguageServerProtocolJSONRPCTests/CodingTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ final class CodingTests: XCTestCase {
209209

210210
let defaultCodingInfo: [CodingUserInfoKey: Any] = [CodingUserInfoKey.messageRegistryKey:MessageRegistry.lspProtocol]
211211

212-
private func checkMessageCoding<Request>(_ value: Request, id: RequestID, json: String, file: StaticString = #file, line: UInt = #line) where Request: RequestType & Equatable {
213-
checkCoding(JSONRPCMessage.request(value, id: id), json: json, userInfo: defaultCodingInfo, file: file, line: line) {
212+
private func checkMessageCoding<Request>(_ value: Request, id: RequestID, json: String, file: StaticString = #filePath, line: UInt = #line) where Request: RequestType & Equatable {
213+
checkCoding(JSONRPCMessage.request(value, id: id), json: json, userInfo: defaultCodingInfo, file: (file), line: line) {
214214

215215
guard case JSONRPCMessage.request(let decodedValueOpaque, let decodedID) = $0, let decodedValue = decodedValueOpaque as? Request else {
216216
XCTFail("decodedValue \($0) does not match expected \(value)", file: file, line: line)
@@ -222,8 +222,8 @@ private func checkMessageCoding<Request>(_ value: Request, id: RequestID, json:
222222
}
223223
}
224224

225-
private func checkMessageCoding<Notification>(_ value: Notification, json: String, file: StaticString = #file, line: UInt = #line) where Notification: NotificationType & Equatable {
226-
checkCoding(JSONRPCMessage.notification(value), json: json, userInfo: defaultCodingInfo, file: file, line: line) {
225+
private func checkMessageCoding<Notification>(_ value: Notification, json: String, file: StaticString = #filePath, line: UInt = #line) where Notification: NotificationType & Equatable {
226+
checkCoding(JSONRPCMessage.notification(value), json: json, userInfo: defaultCodingInfo, file: (file), line: line) {
227227

228228
guard case JSONRPCMessage.notification(let decodedValueOpaque) = $0, let decodedValue = decodedValueOpaque as? Notification else {
229229
XCTFail("decodedValue \($0) does not match expected \(value)", file: file, line: line)
@@ -234,7 +234,7 @@ private func checkMessageCoding<Notification>(_ value: Notification, json: Strin
234234
}
235235
}
236236

237-
private func checkMessageCoding<Response>(_ value: Response, id: RequestID, json: String, file: StaticString = #file, line: UInt = #line) where Response: ResponseType & Equatable {
237+
private func checkMessageCoding<Response>(_ value: Response, id: RequestID, json: String, file: StaticString = #filePath, line: UInt = #line) where Response: ResponseType & Equatable {
238238

239239
let callback: JSONRPCMessage.ResponseTypeCallback = {
240240
return $0 == .string("unknown") ? nil : Response.self
@@ -243,7 +243,7 @@ private func checkMessageCoding<Response>(_ value: Response, id: RequestID, json
243243
var codingInfo = defaultCodingInfo
244244
codingInfo[.responseTypeCallbackKey] = callback
245245

246-
checkCoding(JSONRPCMessage.response(value, id: id), json: json, userInfo: codingInfo, file: file, line: line) {
246+
checkCoding(JSONRPCMessage.response(value, id: id), json: json, userInfo: codingInfo, file: (file), line: line) {
247247

248248
guard case JSONRPCMessage.response(let decodedValueOpaque, let decodedID) = $0, let decodedValue = decodedValueOpaque as? Response else {
249249
XCTFail("decodedValue \($0) does not match expected \(value)", file: file, line: line)
@@ -255,8 +255,8 @@ private func checkMessageCoding<Response>(_ value: Response, id: RequestID, json
255255
}
256256
}
257257

258-
private func checkMessageCoding(_ value: ResponseError, id: RequestID, json: String, file: StaticString = #file, line: UInt = #line) {
259-
checkCoding(JSONRPCMessage.errorResponse(value, id: id), json: json, userInfo: defaultCodingInfo, file: file, line: line) {
258+
private func checkMessageCoding(_ value: ResponseError, id: RequestID, json: String, file: StaticString = #filePath, line: UInt = #line) {
259+
checkCoding(JSONRPCMessage.errorResponse(value, id: id), json: json, userInfo: defaultCodingInfo, file: (file), line: line) {
260260

261261
guard case JSONRPCMessage.errorResponse(let decodedValue, let decodedID) = $0 else {
262262
XCTFail("decodedValue \($0) does not match expected \(value)", file: file, line: line)
@@ -268,7 +268,7 @@ private func checkMessageCoding(_ value: ResponseError, id: RequestID, json: Str
268268
}
269269
}
270270

271-
private func checkMessageDecodingError(_ expected: MessageDecodingError, json: String, userInfo: [CodingUserInfoKey: Any] = defaultCodingInfo, file: StaticString = #file, line: UInt = #line) {
271+
private func checkMessageDecodingError(_ expected: MessageDecodingError, json: String, userInfo: [CodingUserInfoKey: Any] = defaultCodingInfo, file: StaticString = #filePath, line: UInt = #line) {
272272
let data = json.data(using: .utf8)!
273273
let decoder = JSONDecoder()
274274
decoder.userInfo = userInfo

Tests/LanguageServerProtocolJSONRPCTests/MessageParsingTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import XCTest
1717
final class MessageParsingTests: XCTestCase {
1818

1919
func testSplitMessage() {
20-
func check(_ string: String, contentLen: Int? = nil, restLen: Int?, file: StaticString = #file, line: UInt = #line) {
20+
func check(_ string: String, contentLen: Int? = nil, restLen: Int?, file: StaticString = #filePath, line: UInt = #line) {
2121
let bytes: [UInt8] = [UInt8](string.utf8)
2222
guard let ((content, header), rest) = try! bytes.jsonrpcSplitMessage() else {
2323
XCTAssert(restLen == nil, "expected non-empty field", file: file, line: line)
@@ -28,7 +28,7 @@ final class MessageParsingTests: XCTestCase {
2828
XCTAssertEqual(header.contentLength, contentLen, file: file, line: line)
2929
}
3030

31-
func checkError(_ string: String, _ expected: MessageDecodingError, file: StaticString = #file, line: UInt = #line) {
31+
func checkError(_ string: String, _ expected: MessageDecodingError, file: StaticString = #filePath, line: UInt = #line) {
3232
do {
3333
_ = try [UInt8](string.utf8).jsonrpcSplitMessage()
3434
XCTFail("missing expected error", file: file, line: line)
@@ -53,7 +53,7 @@ final class MessageParsingTests: XCTestCase {
5353
}
5454

5555
func testParseHeader() {
56-
func check(_ string: String, header expected: JSONRPCMessageHeader? = nil, restLen: Int?, file: StaticString = #file, line: UInt = #line) {
56+
func check(_ string: String, header expected: JSONRPCMessageHeader? = nil, restLen: Int?, file: StaticString = #filePath, line: UInt = #line) {
5757
let bytes: [UInt8] = [UInt8](string.utf8)
5858
guard let (header, rest) = try! bytes.jsonrcpParseHeader() else {
5959
XCTAssert(restLen == nil, "expected non-empty field", file: file, line: line)
@@ -63,7 +63,7 @@ final class MessageParsingTests: XCTestCase {
6363
XCTAssertEqual(header, expected, file: file, line: line)
6464
}
6565

66-
func checkErrorBytes(_ bytes: [UInt8], _ expected: MessageDecodingError, file: StaticString = #file, line: UInt = #line) {
66+
func checkErrorBytes(_ bytes: [UInt8], _ expected: MessageDecodingError, file: StaticString = #filePath, line: UInt = #line) {
6767
do {
6868
_ = try bytes.jsonrcpParseHeader()
6969
XCTFail("missing expected error", file: file, line: line)
@@ -74,7 +74,7 @@ final class MessageParsingTests: XCTestCase {
7474
}
7575
}
7676

77-
func checkError(_ string: String, _ expected: MessageDecodingError, file: StaticString = #file, line: UInt = #line) {
77+
func checkError(_ string: String, _ expected: MessageDecodingError, file: StaticString = #filePath, line: UInt = #line) {
7878
checkErrorBytes([UInt8](string.utf8), expected, file: file, line: line)
7979
}
8080

@@ -95,7 +95,7 @@ final class MessageParsingTests: XCTestCase {
9595
}
9696

9797
func testParseHeaderField() {
98-
func check(_ string: String, keyLen: Int? = nil, valueLen: Int? = nil, restLen: Int?, file: StaticString = #file, line: UInt = #line) {
98+
func check(_ string: String, keyLen: Int? = nil, valueLen: Int? = nil, restLen: Int?, file: StaticString = #filePath, line: UInt = #line) {
9999
let bytes: [UInt8] = [UInt8](string.utf8)
100100
guard let (kv, rest) = try! bytes.jsonrpcParseHeaderField() else {
101101
XCTAssert(restLen == nil, "expected non-empty field", file: file, line: line)
@@ -112,7 +112,7 @@ final class MessageParsingTests: XCTestCase {
112112
}
113113
}
114114

115-
func checkError(_ string: String, _ expected: MessageDecodingError, file: StaticString = #file, line: UInt = #line) {
115+
func checkError(_ string: String, _ expected: MessageDecodingError, file: StaticString = #filePath, line: UInt = #line) {
116116
do {
117117
_ = try [UInt8](string.utf8).jsonrpcParseHeaderField()
118118
XCTFail("missing expected error", file: file, line: line)

Tests/SKCoreTests/CompilationDatabaseTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import XCTest
1818

1919
final class CompilationDatabaseTests: XCTestCase {
2020
func testSplitShellEscapedCommand() {
21-
func check(_ str: String, _ expected: [String], file: StaticString=#file, line: UInt=#line) {
21+
func check(_ str: String, _ expected: [String], file: StaticString=#filePath, line: UInt=#line) {
2222
XCTAssertEqual(splitShellEscapedCommand(str), expected, file: file, line: line)
2323
}
2424

@@ -61,7 +61,7 @@ final class CompilationDatabaseTests: XCTestCase {
6161
func testEncodeCompDBCommand() {
6262
// Requires JSONEncoder.OutputFormatting.sortedKeys
6363
if #available(macOS 10.13, *) {
64-
func check(_ cmd: CompilationDatabase.Command, _ expected: String, file: StaticString = #file, line: UInt = #line) {
64+
func check(_ cmd: CompilationDatabase.Command, _ expected: String, file: StaticString = #filePath, line: UInt = #line) {
6565
let encoder = JSONEncoder()
6666
encoder.outputFormatting.insert(.sortedKeys)
6767
let encodedString = try! String(data: encoder.encode(cmd), encoding: .utf8)
@@ -78,7 +78,7 @@ final class CompilationDatabaseTests: XCTestCase {
7878
}
7979

8080
func testDecodeCompDBCommand() {
81-
func check(_ str: String, _ expected: CompilationDatabase.Command, file: StaticString = #file, line: UInt = #line) {
81+
func check(_ str: String, _ expected: CompilationDatabase.Command, file: StaticString = #filePath, line: UInt = #line) {
8282
let cmd = try! JSONDecoder().decode(CompilationDatabase.Command.self, from: str.data(using: .utf8)!)
8383
XCTAssertEqual(cmd, expected, file: file, line: line)
8484
}
@@ -305,7 +305,7 @@ final class CompilationDatabaseTests: XCTestCase {
305305
}
306306
}
307307

308-
private func checkCompilationDatabaseBuildSystem(_ compdb: ByteString, file: StaticString = #file, line: UInt = #line, block: (CompilationDatabaseBuildSystem) -> ()) {
308+
private func checkCompilationDatabaseBuildSystem(_ compdb: ByteString, file: StaticString = #filePath, line: UInt = #line, block: (CompilationDatabaseBuildSystem) -> ()) {
309309
let fs = InMemoryFileSystem()
310310
XCTAssertNoThrow(try fs.createDirectory(AbsolutePath("/a")), file: file, line: line)
311311
XCTAssertNoThrow(try fs.writeFileContents(AbsolutePath("/a/compile_commands.json"), bytes: compdb), file: file, line: line)

Tests/SKSupportTests/SupportTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import XCTest
1616

1717
final class SupportTests: XCTestCase {
1818

19-
func checkLines(_ string: String, _ expected: [String], file: StaticString = #file, line: UInt = #line) {
19+
func checkLines(_ string: String, _ expected: [String], file: StaticString = #filePath, line: UInt = #line) {
2020
let table = LineTable(string)
2121
XCTAssertEqual(table.map { String($0) }, expected, file: file, line: line)
2222
}
2323

24-
func checkOffsets(_ string: String, _ expected: [Int], file: StaticString = #file, line: UInt = #line) {
24+
func checkOffsets(_ string: String, _ expected: [Int], file: StaticString = #filePath, line: UInt = #line) {
2525
let table = LineTable(string)
2626
XCTAssertEqual(table.map { string.utf8.distance(from: string.startIndex, to: $0.startIndex) }, expected, file: file, line: line)
2727
}
@@ -68,7 +68,7 @@ final class SupportTests: XCTestCase {
6868
XCTAssertEqual(LineTable("\n")[1], "")
6969
}
7070

71-
func checkLineAndColumns(_ table: LineTable, _ utf8Offset: Int, _ expected: (line: Int, utf16Column: Int)?, file: StaticString = #file, line: UInt = #line) {
71+
func checkLineAndColumns(_ table: LineTable, _ utf8Offset: Int, _ expected: (line: Int, utf16Column: Int)?, file: StaticString = #filePath, line: UInt = #line) {
7272
switch (table.lineAndUTF16ColumnOf(utf8Offset: utf8Offset), expected) {
7373
case (nil, nil):
7474
break
@@ -79,11 +79,11 @@ final class SupportTests: XCTestCase {
7979
}
8080
}
8181

82-
func checkUTF8OffsetOf(_ table: LineTable, _ query: (line: Int, utf16Column: Int), _ expected: Int?, file: StaticString = #file, line: UInt = #line) {
82+
func checkUTF8OffsetOf(_ table: LineTable, _ query: (line: Int, utf16Column: Int), _ expected: Int?, file: StaticString = #filePath, line: UInt = #line) {
8383
XCTAssertEqual(table.utf8OffsetOf(line: query.line, utf16Column: query.utf16Column), expected, file: file, line: line)
8484
}
8585

86-
func checkUTF16ColumnAt(_ table: LineTable, _ query: (line: Int, utf8Column: Int), _ expected: Int?, file: StaticString = #file, line: UInt = #line) {
86+
func checkUTF16ColumnAt(_ table: LineTable, _ query: (line: Int, utf8Column: Int), _ expected: Int?, file: StaticString = #filePath, line: UInt = #line) {
8787
XCTAssertEqual(table.utf16ColumnAt(line: query.line, utf8Column: query.utf8Column), expected, file: file, line: line)
8888
}
8989

Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ final class SwiftPMWorkspaceTests: XCTestCase {
512512
private func checkNot(
513513
_ pattern: String...,
514514
arguments: [String],
515-
file: StaticString = #file,
515+
file: StaticString = #filePath,
516516
line: UInt = #line)
517517
{
518518
if let index = arguments.firstIndex(of: pattern) {
@@ -526,7 +526,7 @@ private func checkNot(
526526
private func check(
527527
_ pattern: String...,
528528
arguments: [String],
529-
file: StaticString = #file,
529+
file: StaticString = #filePath,
530530
line: UInt = #line)
531531
{
532532
guard let index = arguments.firstIndex(of: pattern) else {

0 commit comments

Comments
 (0)