Skip to content

Commit 034d4e2

Browse files
committed
Make SourceKitLSPTests build in Swift 6 mode
1 parent 5302c71 commit 034d4e2

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

Tests/SourceKitLSPTests/BackgroundIndexingTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,10 @@ final class BackgroundIndexingTests: XCTestCase {
202202

203203
// Wait for indexing to finish without elevating the priority
204204
let semaphore = WrappedSemaphore()
205+
let testClient = project.testClient
205206
Task(priority: .low) {
206207
await assertNoThrow {
207-
try await project.testClient.send(PollIndexRequest())
208+
try await testClient.send(PollIndexRequest())
208209
}
209210
semaphore.signal()
210211
}

Tests/SourceKitLSPTests/BuildSystemTests.swift

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import XCTest
2121

2222
/// Build system to be used for testing BuildSystem and BuildSystemDelegate functionality with SourceKitLSPServer
2323
/// and other components.
24-
final class TestBuildSystem: BuildSystem {
25-
var projectRoot: AbsolutePath = try! AbsolutePath(validating: "/")
26-
var indexStorePath: AbsolutePath? = nil
27-
var indexDatabasePath: AbsolutePath? = nil
28-
var indexPrefixMappings: [PathPrefixMapping] = []
24+
actor TestBuildSystem: BuildSystem {
25+
let projectRoot: AbsolutePath = try! AbsolutePath(validating: "/")
26+
let indexStorePath: AbsolutePath? = nil
27+
let indexDatabasePath: AbsolutePath? = nil
28+
let indexPrefixMappings: [PathPrefixMapping] = []
2929

3030
weak var delegate: BuildSystemDelegate?
3131

@@ -34,10 +34,14 @@ final class TestBuildSystem: BuildSystem {
3434
}
3535

3636
/// Build settings by file.
37-
var buildSettingsByFile: [DocumentURI: FileBuildSettings] = [:]
37+
private var buildSettingsByFile: [DocumentURI: FileBuildSettings] = [:]
3838

3939
/// Files currently being watched by our delegate.
40-
var watchedFiles: Set<DocumentURI> = []
40+
private var watchedFiles: Set<DocumentURI> = []
41+
42+
func setBuildSettings(for uri: DocumentURI, to buildSettings: FileBuildSettings) {
43+
buildSettingsByFile[uri] = buildSettings
44+
}
4145

4246
func buildSettings(
4347
for document: DocumentURI,
@@ -158,7 +162,7 @@ final class BuildSystemTests: XCTestCase {
158162
}
159163
"""
160164

161-
buildSystem.buildSettingsByFile[doc] = FileBuildSettings(compilerArguments: args)
165+
await buildSystem.setBuildSettings(for: doc, to: FileBuildSettings(compilerArguments: args))
162166

163167
let documentManager = await self.testClient.server._documentManager
164168

@@ -171,7 +175,7 @@ final class BuildSystemTests: XCTestCase {
171175
// Modify the build settings and inform the delegate.
172176
// This should trigger a new publish diagnostics and we should no longer have errors.
173177
let newSettings = FileBuildSettings(compilerArguments: args + ["-DFOO"])
174-
buildSystem.buildSettingsByFile[doc] = newSettings
178+
await buildSystem.setBuildSettings(for: doc, to: newSettings)
175179

176180
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
177181

@@ -190,7 +194,7 @@ final class BuildSystemTests: XCTestCase {
190194
let doc = DocumentURI.for(.swift)
191195
let args = FallbackBuildSystem(buildSetup: .default).buildSettings(for: doc, language: .swift)!.compilerArguments
192196

193-
buildSystem.buildSettingsByFile[doc] = FileBuildSettings(compilerArguments: args)
197+
await buildSystem.setBuildSettings(for: doc, to: FileBuildSettings(compilerArguments: args))
194198

195199
let text = """
196200
#if FOO
@@ -210,7 +214,7 @@ final class BuildSystemTests: XCTestCase {
210214
// Modify the build settings and inform the delegate.
211215
// This should trigger a new publish diagnostics and we should no longer have errors.
212216
let newSettings = FileBuildSettings(compilerArguments: args + ["-DFOO"])
213-
buildSystem.buildSettingsByFile[doc] = newSettings
217+
await buildSystem.setBuildSettings(for: doc, to: newSettings)
214218

215219
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
216220

@@ -244,7 +248,7 @@ final class BuildSystemTests: XCTestCase {
244248
// Modify the build settings and inform the delegate.
245249
// This should trigger a new publish diagnostics and we should see a diagnostic.
246250
let newSettings = FileBuildSettings(compilerArguments: args)
247-
buildSystem.buildSettingsByFile[doc] = newSettings
251+
await buildSystem.setBuildSettings(for: doc, to: newSettings)
248252

249253
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
250254

@@ -279,7 +283,7 @@ final class BuildSystemTests: XCTestCase {
279283
XCTAssertEqual(text, try documentManager.latestSnapshot(doc).text)
280284

281285
// Swap from fallback settings to primary build system settings.
282-
buildSystem.buildSettingsByFile[doc] = primarySettings
286+
await buildSystem.setBuildSettings(for: doc, to: primarySettings)
283287

284288
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
285289

Tests/SourceKitLSPTests/CodeActionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private typealias CodeActionCapabilities = TextDocumentClientCapabilities.CodeAc
2020
private typealias CodeActionLiteralSupport = CodeActionCapabilities.CodeActionLiteralSupport
2121
private typealias CodeActionKindCapabilities = CodeActionLiteralSupport.CodeActionKind
2222

23-
private var clientCapabilitiesWithCodeActionSupport: ClientCapabilities = {
23+
private let clientCapabilitiesWithCodeActionSupport: ClientCapabilities = {
2424
var documentCapabilities = TextDocumentClientCapabilities()
2525
var codeActionCapabilities = CodeActionCapabilities()
2626
let codeActionKinds = CodeActionKindCapabilities(valueSet: [.refactor, .quickFix])

Tests/SourceKitLSPTests/LocalSwiftTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,9 @@ final class LocalSwiftTests: XCTestCase {
13521352
let uri = DocumentURI(url)
13531353

13541354
let reusedNodeCallback = self.expectation(description: "reused node callback called")
1355-
var reusedNodes: [Syntax] = []
1355+
// nonisolated(unsafe) is fine because the variable will only be read after all writes from reusedNodeCallback are
1356+
// done.
1357+
nonisolated(unsafe) var reusedNodes: [Syntax] = []
13561358
let swiftLanguageService =
13571359
await testClient.server._languageService(for: uri, .swift, in: testClient.server.workspaceForDocument(uri: uri)!)
13581360
as! SwiftLanguageService

0 commit comments

Comments
 (0)