Skip to content

Commit 5a1e531

Browse files
committed
Fix broken tests
- Properly wait for workspace loading to be done
1 parent f0b58fd commit 5a1e531

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

crates/rust-analyzer/tests/heavy_tests/support.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ use lsp_types::{
1212
notification::{DidOpenTextDocument, Exit},
1313
request::Shutdown,
1414
ClientCapabilities, DidOpenTextDocumentParams, GotoCapability, TextDocumentClientCapabilities,
15-
TextDocumentIdentifier, TextDocumentItem, Url,
15+
TextDocumentIdentifier, TextDocumentItem, Url, WorkDoneProgress,
1616
};
1717
use serde::Serialize;
1818
use serde_json::{to_string_pretty, Value};
1919
use tempfile::TempDir;
2020
use test_utils::{find_mismatch, parse_fixture};
2121

22+
use req::{ProgressParams, ProgressParamsValue};
2223
use rust_analyzer::{main_loop, req, ServerConfig};
2324

2425
pub struct Project<'a> {
@@ -201,10 +202,14 @@ impl Server {
201202
}
202203
pub fn wait_until_workspace_is_loaded(&self) {
203204
self.wait_for_message_cond(1, &|msg: &Message| match msg {
204-
Message::Notification(n) if n.method == "window/showMessage" => {
205-
let msg =
206-
n.clone().extract::<req::ShowMessageParams>("window/showMessage").unwrap();
207-
msg.message.starts_with("workspace loaded")
205+
Message::Notification(n) if n.method == "$/progress" => {
206+
match n.clone().extract::<ProgressParams>("$/progress").unwrap() {
207+
ProgressParams {
208+
token: req::ProgressToken::String(ref token),
209+
value: ProgressParamsValue::WorkDone(WorkDoneProgress::End(_)),
210+
} if token == "rustAnalyzer/startup" => true,
211+
_ => false,
212+
}
208213
}
209214
_ => false,
210215
})

0 commit comments

Comments
 (0)