@@ -554,27 +554,30 @@ final class BackgroundIndexingTests: XCTestCase {
554
554
DidChangeWatchedFilesNotification ( changes: [ FileEvent ( uri: try project. uri ( for: " MyFile.swift " ) , type: . changed) ] )
555
555
)
556
556
557
- let diagnosticRefreshReceived = self . expectation ( description: " Received diagnostic refresh request " )
558
- project. testClient. handleNextRequest { ( _: DiagnosticsRefreshRequest ) in
559
- diagnosticRefreshReceived. fulfill ( )
560
- return VoidResponse ( )
561
- }
562
-
563
557
// Send a document request for `uri` to trigger re-preparation of its target. We don't actually care about the
564
558
// response for this request. Instead, we wait until SourceKit-LSP sends us a `DiagnosticsRefreshRequest`,
565
559
// indicating that the target of `uri` has been prepared.
566
560
_ = try await project. testClient. send (
567
561
DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
568
562
)
569
- try await fulfillmentOfOrThrow ( [ diagnosticRefreshReceived] )
570
563
571
- let updatedDiagnostics = try await project. testClient. send (
572
- DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
573
- )
574
- guard case . full( let updatedDiagnostics) = updatedDiagnostics else {
575
- XCTFail ( " Expected full diagnostics " )
576
- return
564
+ let receivedEmptyDiagnostics = self . expectation ( description: " Received diagnostic refresh request " )
565
+ project. testClient. handleNextRequest { ( _: DiagnosticsRefreshRequest ) in
566
+ Task {
567
+ let updatedDiagnostics = try await project. testClient. send (
568
+ DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
569
+ )
570
+ guard case . full( let updatedDiagnostics) = updatedDiagnostics else {
571
+ XCTFail ( " Expected full diagnostics " )
572
+ return
573
+ }
574
+ if updatedDiagnostics. items. isEmpty {
575
+ receivedEmptyDiagnostics. fulfill ( )
576
+ }
577
+ }
578
+ return VoidResponse ( )
577
579
}
578
- XCTAssertEqual ( updatedDiagnostics. items, [ ] )
580
+
581
+ try await fulfillmentOfOrThrow ( [ receivedEmptyDiagnostics] )
579
582
}
580
583
}
0 commit comments