Skip to content

Commit 6d4953b

Browse files
committed
Make tests pass with Xcode 15.4
We are no longer skipping these tests, which means that we need to make them account for different error messages emitted by Swift 5.10. I added warnings behind `#if compiler(>=6.1)` to give us a reminder that we can remove these checks when we no longer support running SourceKit-LSP with SwiftPM from Swift 5.10. Swift 6.1 doesn’t have to be this cut-off point but it’s the most likely candidate for now if we want to support the current and last Swift version from tip SourceKit-LSP.
1 parent b7b225c commit 6d4953b

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Sources/SKSwiftPMWorkspace/SwiftPMBuildSystem.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ extension SwiftPMBuildSystem: SKCore.BuildSystem {
363363
private func compilerArguments(for file: URL, in buildTarget: any SwiftBuildTarget) async throws -> [String] {
364364
let compileArguments = try buildTarget.compileArguments(for: file)
365365

366+
#if compiler(>=6.1)
367+
#warning("When we drop support for Swift 5.10 we no longer need to adjust compiler arguments for the Modules move")
368+
#endif
366369
// Fix up compiler arguments that point to a `/Modules` subdirectory if the Swift version in the toolchain is less
367370
// than 6.0 because it places the modules one level higher up.
368371
let toolchainVersion = await orLog("Getting Swift version") { try await toolchainRegistry.default?.swiftVersion }

Tests/SourceKitLSPTests/DependencyTrackingTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ final class DependencyTrackingTests: XCTestCase {
5050
// Semantic analysis: expect module import error.
5151
XCTAssertEqual(initialDiags.diagnostics.count, 1)
5252
if let diagnostic = initialDiags.diagnostics.first {
53+
#if compiler(>=6.1)
54+
#warning("When we drop support for Swift 5.10 we no longer need to check for the Objective-C error message")
55+
#endif
5356
XCTAssert(
5457
diagnostic.message.contains("Could not build Objective-C module")
5558
|| diagnostic.message.contains("No such module"),

Tests/SourceKitLSPTests/PublishDiagnosticsTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,14 @@ final class PublishDiagnosticsTests: XCTestCase {
186186

187187
_ = try project.openDocument("LibB.swift")
188188
let diagnosticsBeforeBuilding = try await project.testClient.nextDiagnosticsNotification()
189-
XCTAssert(diagnosticsBeforeBuilding.diagnostics.contains(where: { $0.message == "No such module 'LibA'" }))
189+
XCTAssert(
190+
diagnosticsBeforeBuilding.diagnostics.contains(where: {
191+
#if compiler(>=6.1)
192+
#warning("When we drop support for Swift 5.10 we no longer need to check for the Objective-C error message")
193+
#endif
194+
return $0.message == "No such module 'LibA'" || $0.message == "Could not build Objective-C module 'LibA'"
195+
})
196+
)
190197

191198
try await SwiftPMTestProject.build(at: project.scratchDirectory)
192199

Tests/SourceKitLSPTests/PullDiagnosticsTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@ final class PullDiagnosticsTests: XCTestCase {
222222
XCTFail("Expected full diagnostics report")
223223
return
224224
}
225-
XCTAssert(fullReportBeforeBuilding.items.contains(where: { $0.message == "No such module 'LibA'" }))
225+
XCTAssert(
226+
fullReportBeforeBuilding.items.contains(where: {
227+
#if compiler(>=6.1)
228+
#warning("When we drop support for Swift 5.10 we no longer need to check for the Objective-C error message")
229+
#endif
230+
return $0.message == "No such module 'LibA'" || $0.message == "Could not build Objective-C module 'LibA'"
231+
})
232+
)
226233

227234
let diagnosticsRefreshRequestReceived = self.expectation(description: "DiagnosticsRefreshRequest received")
228235
project.testClient.handleSingleRequest { (request: DiagnosticsRefreshRequest) in

0 commit comments

Comments
 (0)