From 30b8468c7eebd5bad26674dc58009f3b2c3929fb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 28 Jan 2021 19:10:48 +0300 Subject: Simplify heavy tests Progress notifications are edge triggered, while status is level triggered. This makes it a hared to misuse signal for the readiness of the server. --- .../rust-analyzer/tests/rust-analyzer/support.rs | 32 ++++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/tests/rust-analyzer/support.rs b/crates/rust-analyzer/tests/rust-analyzer/support.rs index 4c4b994fe..453ce4fa8 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/support.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/support.rs @@ -8,14 +8,11 @@ use std::{ use crossbeam_channel::{after, select, Receiver}; use lsp_server::{Connection, Message, Notification, Request}; -use lsp_types::{ - notification::Exit, request::Shutdown, TextDocumentIdentifier, Url, WorkDoneProgress, -}; -use lsp_types::{ProgressParams, ProgressParamsValue}; +use lsp_types::{notification::Exit, request::Shutdown, TextDocumentIdentifier, Url}; use project_model::ProjectManifest; -use rust_analyzer::{config::Config, main_loop}; +use rust_analyzer::{config::Config, lsp_ext, main_loop}; use serde::Serialize; -use serde_json::{to_string_pretty, Value}; +use serde_json::{json, to_string_pretty, Value}; use test_utils::{find_mismatch, Fixture}; use vfs::AbsPathBuf; @@ -106,9 +103,12 @@ impl<'a> Project<'a> { ..Default::default() }), window: Some(lsp_types::WindowClientCapabilities { - work_done_progress: Some(true), + work_done_progress: Some(false), ..Default::default() }), + experimental: Some(json!({ + "statusNotification": true, + })), ..Default::default() }, ); @@ -192,9 +192,6 @@ impl Server { while let Some(msg) = self.recv().unwrap_or_else(|Timeout| panic!("timeout: {:?}", r)) { match msg { Message::Request(req) => { - if req.method == "window/workDoneProgress/create" { - continue; - } if req.method == "client/registerCapability" { let params = req.params.to_string(); if ["workspace/didChangeWatchedFiles", "textDocument/didSave"] @@ -220,14 +217,13 @@ impl Server { } pub(crate) fn wait_until_workspace_is_loaded(self) -> Server { self.wait_for_message_cond(1, &|msg: &Message| match msg { - Message::Notification(n) if n.method == "$/progress" => { - match n.clone().extract::("$/progress").unwrap() { - ProgressParams { - token: lsp_types::ProgressToken::String(ref token), - value: ProgressParamsValue::WorkDone(WorkDoneProgress::End(_)), - } if token == "rustAnalyzer/roots scanned" => true, - _ => false, - } + Message::Notification(n) if n.method == "rust-analyzer/status" => { + let status = n + .clone() + .extract::("rust-analyzer/status") + .unwrap() + .status; + matches!(status, lsp_ext::Status::Ready) } _ => false, }) -- cgit v1.2.3