From 5a1e531176bf6dab75e6c33cc30be6c5bb3ff345 Mon Sep 17 00:00:00 2001 From: Steffen Lyngbaek Date: Fri, 13 Mar 2020 22:06:49 -0700 Subject: Fix broken tests - Properly wait for workspace loading to be done --- crates/rust-analyzer/tests/heavy_tests/support.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs index e28ae61fe..1d7062bdf 100644 --- a/crates/rust-analyzer/tests/heavy_tests/support.rs +++ b/crates/rust-analyzer/tests/heavy_tests/support.rs @@ -12,13 +12,14 @@ use lsp_types::{ notification::{DidOpenTextDocument, Exit}, request::Shutdown, ClientCapabilities, DidOpenTextDocumentParams, GotoCapability, TextDocumentClientCapabilities, - TextDocumentIdentifier, TextDocumentItem, Url, + TextDocumentIdentifier, TextDocumentItem, Url, WorkDoneProgress, }; use serde::Serialize; use serde_json::{to_string_pretty, Value}; use tempfile::TempDir; use test_utils::{find_mismatch, parse_fixture}; +use req::{ProgressParams, ProgressParamsValue}; use rust_analyzer::{main_loop, req, ServerConfig}; pub struct Project<'a> { @@ -201,10 +202,14 @@ impl Server { } pub fn wait_until_workspace_is_loaded(&self) { self.wait_for_message_cond(1, &|msg: &Message| match msg { - Message::Notification(n) if n.method == "window/showMessage" => { - let msg = - n.clone().extract::("window/showMessage").unwrap(); - msg.message.starts_with("workspace loaded") + Message::Notification(n) if n.method == "$/progress" => { + match n.clone().extract::("$/progress").unwrap() { + ProgressParams { + token: req::ProgressToken::String(ref token), + value: ProgressParamsValue::WorkDone(WorkDoneProgress::End(_)), + } if token == "rustAnalyzer/startup" => true, + _ => false, + } } _ => false, }) -- cgit v1.2.3