Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Tests/SourceKitLSPTests/BackgroundIndexingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2633,14 +2633,18 @@ final class BackgroundIndexingTests: XCTestCase {
func testTargetsAreIndexedInDependencyOrder() async throws {
// We want to prepare low-level targets before high-level targets to make progress on indexing more quickly.
let preparationRequests = ThreadSafeBox<[BuildTargetPrepareRequest]>(initialValue: [])
let twoPreparationRequestsReceived = self.expectation(description: "Received two preparation requests")
let testHooks = Hooks(
buildServerHooks: BuildServerHooks(preHandleRequest: { request in
if let request = request as? BuildTargetPrepareRequest {
preparationRequests.value.append(request)
if preparationRequests.value.count >= 2 {
twoPreparationRequestsReceived.fulfill()
}
}
})
)
_ = try await SwiftPMTestProject(
let project = try await SwiftPMTestProject(
files: [
"LibA/LibA.swift": "",
"LibB/LibB.swift": "",
Expand All @@ -2656,15 +2660,20 @@ final class BackgroundIndexingTests: XCTestCase {
""",
hooks: testHooks,
enableBackgroundIndexing: true,
pollIndex: true
pollIndex: false
)
// We can't poll the index using `workspace/synchronize` because that elevates the priority of the indexing requests
// in a non-deterministic order (due to the way ). If LibB's priority gets elevated before LibA's, then LibB will
// get prepared first, which is contrary to the background behavior we want to check here.
try await fulfillmentOfOrThrow(twoPreparationRequestsReceived)
XCTAssertEqual(
preparationRequests.value.flatMap(\.targets),
[
try BuildTargetIdentifier(target: "LibA", destination: .target),
try BuildTargetIdentifier(target: "LibB", destination: .target),
]
)
withExtendedLifetime(project) {}
}

func testIndexingProgressDoesNotGetStuckIfThereAreNoSourceFilesInTarget() async throws {
Expand Down