Skip to content

Commit 2270128

Browse files
committed
Make SourceKitLSPTests build in Swift 6 mode
1 parent 0b01ede commit 2270128

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,
@@ -160,7 +164,7 @@ final class BuildSystemTests: XCTestCase {
160164
}
161165
"""
162166

163-
buildSystem.buildSettingsByFile[doc] = FileBuildSettings(compilerArguments: args)
167+
await buildSystem.setBuildSettings(for: doc, to: FileBuildSettings(compilerArguments: args))
164168

165169
let documentManager = await self.testClient.server._documentManager
166170

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

178182
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
179183

@@ -194,7 +198,7 @@ final class BuildSystemTests: XCTestCase {
194198
.buildSettings(for: doc, language: .swift)!
195199
.compilerArguments
196200

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

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

219223
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
220224

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

253257
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
254258

@@ -283,7 +287,7 @@ final class BuildSystemTests: XCTestCase {
283287
XCTAssertEqual(text, try documentManager.latestSnapshot(doc).text)
284288

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

288292
await buildSystem.delegate?.fileBuildSettingsChanged([doc])
289293

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)