Skip to content

Commit 7c83ff5

Browse files
committed
Update assertions to add more detail
`testSystemSwiftInterface` is called multiple times in a single test, add file/line to the test output so it's clear which case actually failed.
1 parent c0f1469 commit 7c83ff5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Tests/SourceKitLSPTests/SwiftInterfaceTests.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ final class SwiftInterfaceTests: XCTestCase {
114114
_ testLoc: TestLocation,
115115
ws: SKSwiftPMTestWorkspace,
116116
swiftInterfaceFile: String,
117-
linePrefix: String
117+
linePrefix: String,
118+
file: StaticString = #filePath,
119+
line: UInt = #line
118120
) throws {
119121
try ws.openDocument(testLoc.url, language: .swift)
120122
let definition = try ws.sk.sendSync(DefinitionRequest(
@@ -125,12 +127,12 @@ final class SwiftInterfaceTests: XCTestCase {
125127
return
126128
}
127129
let location = try XCTUnwrap(jump.first)
128-
XCTAssertTrue(location.uri.pseudoPath.hasSuffix(swiftInterfaceFile), "Path was: '\(location.uri.pseudoPath)'")
130+
XCTAssertTrue(location.uri.pseudoPath.hasSuffix(swiftInterfaceFile), "Expected '\(swiftInterfaceFile)' but returned path was '\(location.uri.pseudoPath)'", file: file, line: line)
129131
// load contents of swiftinterface
130132
let contents = try XCTUnwrap(location.uri.fileURL.flatMap({ try String(contentsOf: $0, encoding: .utf8) }))
131133
let lineTable = LineTable(contents)
132-
let line = lineTable[location.range.lowerBound.line]
133-
XCTAssert(line.hasPrefix(linePrefix), "Full line was: '\(line)'")
134+
let lineText = lineTable[location.range.lowerBound.line]
135+
XCTAssert(lineText.hasPrefix(linePrefix), "Expected '\(linePrefix)' but first line was '\(lineText)'", file: file, line: line)
134136
ws.closeDocument(testLoc.url)
135137
}
136138

0 commit comments

Comments
 (0)