Skip to content

Commit cf8492a

Browse files
committed
Make testImplicitCancellationOnEdit more robust
Instead of adding an arbitrary `Task.sleep` that should give us enough time to send the `textDocument/didChange` notification, use a semaphore to coordinate the messages.
1 parent b3a73f6 commit cf8492a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Tests/SourceKitLSPTests/SemanticTokensTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,11 +894,11 @@ final class SemanticTokensTests: XCTestCase {
894894
}
895895

896896
func testImplicitCancellationOnEdit() async throws {
897+
let didSendDocumentChange = WrappedSemaphore(name: "Did send document change")
897898
let testClient = try await TestSourceKitLSPClient(
898899
hooks: Hooks(preHandleRequest: { request in
899900
if request is DocumentSemanticTokensRequest {
900-
// Sleep long enough for the edit to be handled
901-
try? await Task.sleep(for: .seconds(10))
901+
didSendDocumentChange.waitOrXCTFail()
902902
}
903903
})
904904
)
@@ -916,6 +916,7 @@ final class SemanticTokensTests: XCTestCase {
916916
contentChanges: [TextDocumentContentChangeEvent(range: Range(positions["1️⃣"]), text: "let x = 1")]
917917
)
918918
)
919+
didSendDocumentChange.signal()
919920
try await fulfillmentOfOrThrow([receivedSemanticTokensResponse])
920921
}
921922

0 commit comments

Comments
 (0)