@@ -1978,7 +1978,8 @@ final class BackgroundIndexingTests: XCTestCase {
19781978 """
19791979 ] ,
19801980 buildServer: BuildServer . self,
1981- enableBackgroundIndexing: true
1981+ enableBackgroundIndexing: true ,
1982+ pollIndex: false
19821983 )
19831984 let fileUrl = try XCTUnwrap ( project. uri ( for: " Test.swift " ) . fileURL)
19841985
@@ -2141,7 +2142,6 @@ final class BackgroundIndexingTests: XCTestCase {
21412142 buildServer: BuildServer . self,
21422143 enableBackgroundIndexing: true
21432144 )
2144- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
21452145
21462146 let symbols = try await project. testClient. send ( WorkspaceSymbolsRequest ( query: " myTestFunc " ) )
21472147 XCTAssertEqual (
@@ -2220,13 +2220,9 @@ final class BackgroundIndexingTests: XCTestCase {
22202220 }
22212221
22222222 func initializeBuildRequest( _ request: InitializeBuildRequest ) async throws -> InitializeBuildResponse {
2223- return initializationResponse (
2224- initializeData: SourceKitInitializeBuildResponseData (
2225- indexDatabasePath: try projectRoot. appendingPathComponent ( " index-db " ) . filePath,
2226- indexStorePath: try projectRoot. appendingPathComponent ( " index-store " ) . filePath,
2227- prepareProvider: true ,
2228- sourceKitOptionsProvider: true
2229- )
2223+ return try initializationResponseSupportingBackgroundIndexing (
2224+ projectRoot: projectRoot,
2225+ outputPathsProvider: false
22302226 )
22312227 }
22322228
@@ -2264,7 +2260,6 @@ final class BackgroundIndexingTests: XCTestCase {
22642260 enableBackgroundIndexing: true ,
22652261 testScratchDir: scratchDirectory
22662262 )
2267- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
22682263
22692264 // Ensure that changing `/private/tmp/.../test.c` only causes `/tmp/.../test.c` to be indexed, not
22702265 // `/private/tmp/.../test.c`.
@@ -2375,7 +2370,6 @@ final class BackgroundIndexingTests: XCTestCase {
23752370 buildServer: BuildServer . self,
23762371 enableBackgroundIndexing: true
23772372 )
2378- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
23792373
23802374 let ( libAUri, libAPositions) = try project. openDocument ( " LibA.swift " )
23812375 let libATypeHierarchyPrepare = try await project. testClient. send (
@@ -2493,7 +2487,6 @@ final class BackgroundIndexingTests: XCTestCase {
24932487 buildServer: BuildServer . self,
24942488 enableBackgroundIndexing: true
24952489 )
2496- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
24972490
24982491 let workspaceSymbolsBeforeUpdate = try await project. testClient. send ( WorkspaceSymbolsRequest ( query: " myTest " ) )
24992492 XCTAssertEqual ( workspaceSymbolsBeforeUpdate? . compactMap ( \. symbolInformation? . name) , [ " myTestA " , " myTestB " ] )
@@ -2539,6 +2532,59 @@ final class BackgroundIndexingTests: XCTestCase {
25392532 // Check that we don't enter an infinite loop trying to index the circular symlink.
25402533 try await project. testClient. send ( SynchronizeRequest ( index: true ) )
25412534 }
2535+
2536+ func testBuildSystemDoesNotReturnIndexUnitOutputPath( ) async throws {
2537+ final class BuildSystem : CustomBuildServer {
2538+ let inProgressRequestsTracker = CustomBuildServerInProgressRequestTracker ( )
2539+ private let projectRoot : URL
2540+
2541+ required init ( projectRoot: URL , connectionToSourceKitLSP: any LanguageServerProtocol . Connection ) {
2542+ self . projectRoot = projectRoot
2543+ }
2544+
2545+ func initializeBuildRequest( _ request: InitializeBuildRequest ) async throws -> InitializeBuildResponse {
2546+ return try initializationResponseSupportingBackgroundIndexing (
2547+ projectRoot: projectRoot,
2548+ outputPathsProvider: true
2549+ )
2550+ }
2551+
2552+ func buildTargetSourcesRequest( _ request: BuildTargetSourcesRequest ) async throws -> BuildTargetSourcesResponse {
2553+ return BuildTargetSourcesResponse ( items: [
2554+ SourcesItem (
2555+ target: . dummy,
2556+ sources: [
2557+ sourceItem (
2558+ for: projectRoot. appendingPathComponent ( " test.swift " ) ,
2559+ outputPath: fakeOutputPath ( for: " test.swift " , in: " dummy " )
2560+ )
2561+ ]
2562+ )
2563+ ] )
2564+ }
2565+
2566+ func textDocumentSourceKitOptionsRequest(
2567+ _ request: TextDocumentSourceKitOptionsRequest
2568+ ) async throws -> TextDocumentSourceKitOptionsResponse ? {
2569+ var arguments = [ request. textDocument. uri. pseudoPath, " -o " , fakeOutputPath ( for: " test.swift " , in: " dummy " ) ]
2570+ if let defaultSDKPath {
2571+ arguments += [ " -sdk " , defaultSDKPath]
2572+ }
2573+ return TextDocumentSourceKitOptionsResponse ( compilerArguments: arguments)
2574+ }
2575+ }
2576+
2577+ let project = try await CustomBuildServerTestProject (
2578+ files: [
2579+ " test.swift " : " func myTestFunc() {} "
2580+ ] ,
2581+ buildServer: BuildSystem . self,
2582+ enableBackgroundIndexing: true
2583+ )
2584+
2585+ let symbols = try await project. testClient. send ( WorkspaceSymbolsRequest ( query: " myTestFu " ) )
2586+ XCTAssertEqual ( symbols? . compactMap ( \. symbolInformation? . name) , [ " myTestFunc() " ] )
2587+ }
25422588}
25432589
25442590extension HoverResponseContents {
0 commit comments