Skip to content

Commit 7adf2a4

Browse files
committed
Allow serverOptions to be specified on SwiftPMTestProject
This will allow us to conditionally enable background indexing in tests
1 parent b9d5a66 commit 7adf2a4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Sources/SKTestSupport/MultiFileTestProject.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import Foundation
1414
import LanguageServerProtocol
1515
import SKCore
16+
import SourceKitLSP
1617

1718
/// The location of a test file within test workspace.
1819
public struct RelativeFileLocation: Hashable, ExpressibleByStringLiteral {
@@ -79,6 +80,7 @@ public class MultiFileTestProject {
7980
public init(
8081
files: [RelativeFileLocation: String],
8182
workspaces: (URL) async throws -> [WorkspaceFolder] = { [WorkspaceFolder(uri: DocumentURI($0))] },
83+
serverOptions: SourceKitLSPServer.Options = .testDefault,
8284
usePullDiagnostics: Bool = true,
8385
testName: String = #function
8486
) async throws {
@@ -109,6 +111,7 @@ public class MultiFileTestProject {
109111
self.fileData = fileData
110112

111113
self.testClient = try await TestSourceKitLSPClient(
114+
serverOptions: serverOptions,
112115
usePullDiagnostics: usePullDiagnostics,
113116
workspaceFolders: workspaces(scratchDirectory),
114117
cleanUp: { [scratchDirectory] in

Sources/SKTestSupport/SwiftPMTestProject.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import Foundation
1414
import LanguageServerProtocol
1515
@_spi(Testing) import SKCore
16+
import SourceKitLSP
1617
import TSCBasic
1718

1819
public class SwiftPMTestProject: MultiFileTestProject {
@@ -41,6 +42,7 @@ public class SwiftPMTestProject: MultiFileTestProject {
4142
workspaces: (URL) async throws -> [WorkspaceFolder] = { [WorkspaceFolder(uri: DocumentURI($0))] },
4243
build: Bool = false,
4344
allowBuildFailure: Bool = false,
45+
serverOptions: SourceKitLSPServer.Options = .testDefault,
4446
usePullDiagnostics: Bool = true,
4547
testName: String = #function
4648
) async throws {
@@ -63,6 +65,7 @@ public class SwiftPMTestProject: MultiFileTestProject {
6365
try await super.init(
6466
files: filesByPath,
6567
workspaces: workspaces,
68+
serverOptions: serverOptions,
6669
usePullDiagnostics: usePullDiagnostics,
6770
testName: testName
6871
)

0 commit comments

Comments
 (0)