Skip to content

Fix a non-deterministic test failure #792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
14 changes: 7 additions & 7 deletions Tests/SourceKitLSPTests/LocalSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ final class LocalSwiftTests: XCTestCase {
swiftLanguageServer.reusedNodeCallback = { reusedNodes.append($0) }
sk.allowUnexpectedNotification = false

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
sk.sendNoteSync(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
uri: uri,
language: .swift,
version: 0,
Expand All @@ -1497,20 +1497,20 @@ final class LocalSwiftTests: XCTestCase {
class bar {
}
"""
)))

let didChangeTextDocumentExpectation = self.expectation(description: "didChangeTextDocument")
)), { (note: LanguageServerProtocol.Notification<PublishDiagnosticsNotification>) -> Void in
log("Received diagnostics for open - syntactic")
}, { (note: LanguageServerProtocol.Notification<PublishDiagnosticsNotification>) -> Void in
log("Received diagnostics for open - semantic")
})

sk.sendNoteSync(DidChangeTextDocumentNotification(textDocument: .init(uri, version: 1), contentChanges: [
.init(range: Range(Position(line: 2, utf16index: 7)), text: "a"),
]), { (note: LanguageServerProtocol.Notification<PublishDiagnosticsNotification>) -> Void in
log("Received diagnostics for text edit - syntactic")
didChangeTextDocumentExpectation.fulfill()
}, { (note: LanguageServerProtocol.Notification<PublishDiagnosticsNotification>) -> Void in
log("Received diagnostics for text edit - semantic")
})

self.wait(for: [didChangeTextDocumentExpectation], timeout: defaultTimeout)

XCTAssertEqual(reusedNodes.count, 1)

let firstNode = try XCTUnwrap(reusedNodes.first)
Expand Down