@@ -1978,7 +1978,8 @@ final class BackgroundIndexingTests: XCTestCase {
1978
1978
"""
1979
1979
] ,
1980
1980
buildServer: BuildServer . self,
1981
- enableBackgroundIndexing: true
1981
+ enableBackgroundIndexing: true ,
1982
+ pollIndex: false
1982
1983
)
1983
1984
let fileUrl = try XCTUnwrap ( project. uri ( for: " Test.swift " ) . fileURL)
1984
1985
@@ -2141,7 +2142,6 @@ final class BackgroundIndexingTests: XCTestCase {
2141
2142
buildServer: BuildServer . self,
2142
2143
enableBackgroundIndexing: true
2143
2144
)
2144
- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
2145
2145
2146
2146
let symbols = try await project. testClient. send ( WorkspaceSymbolsRequest ( query: " myTestFunc " ) )
2147
2147
XCTAssertEqual (
@@ -2220,13 +2220,9 @@ final class BackgroundIndexingTests: XCTestCase {
2220
2220
}
2221
2221
2222
2222
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
2230
2226
)
2231
2227
}
2232
2228
@@ -2264,7 +2260,6 @@ final class BackgroundIndexingTests: XCTestCase {
2264
2260
enableBackgroundIndexing: true ,
2265
2261
testScratchDir: scratchDirectory
2266
2262
)
2267
- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
2268
2263
2269
2264
// Ensure that changing `/private/tmp/.../test.c` only causes `/tmp/.../test.c` to be indexed, not
2270
2265
// `/private/tmp/.../test.c`.
@@ -2375,7 +2370,6 @@ final class BackgroundIndexingTests: XCTestCase {
2375
2370
buildServer: BuildServer . self,
2376
2371
enableBackgroundIndexing: true
2377
2372
)
2378
- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
2379
2373
2380
2374
let ( libAUri, libAPositions) = try project. openDocument ( " LibA.swift " )
2381
2375
let libATypeHierarchyPrepare = try await project. testClient. send (
@@ -2493,7 +2487,6 @@ final class BackgroundIndexingTests: XCTestCase {
2493
2487
buildServer: BuildServer . self,
2494
2488
enableBackgroundIndexing: true
2495
2489
)
2496
- try await project. testClient. send ( SynchronizeRequest ( index: true ) )
2497
2490
2498
2491
let workspaceSymbolsBeforeUpdate = try await project. testClient. send ( WorkspaceSymbolsRequest ( query: " myTest " ) )
2499
2492
XCTAssertEqual ( workspaceSymbolsBeforeUpdate? . compactMap ( \. symbolInformation? . name) , [ " myTestA " , " myTestB " ] )
@@ -2539,6 +2532,59 @@ final class BackgroundIndexingTests: XCTestCase {
2539
2532
// Check that we don't enter an infinite loop trying to index the circular symlink.
2540
2533
try await project. testClient. send ( SynchronizeRequest ( index: true ) )
2541
2534
}
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
+ }
2542
2588
}
2543
2589
2544
2590
extension HoverResponseContents {
0 commit comments