7478: Simplify heavy tests r=edwin0cheng a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-01-28 16:25:53 +00:00 committed by GitHub
commit f421ee6722
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,14 +8,11 @@ use std::{
use crossbeam_channel::{after, select, Receiver}; use crossbeam_channel::{after, select, Receiver};
use lsp_server::{Connection, Message, Notification, Request}; use lsp_server::{Connection, Message, Notification, Request};
use lsp_types::{ use lsp_types::{notification::Exit, request::Shutdown, TextDocumentIdentifier, Url};
notification::Exit, request::Shutdown, TextDocumentIdentifier, Url, WorkDoneProgress,
};
use lsp_types::{ProgressParams, ProgressParamsValue};
use project_model::ProjectManifest; 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::Serialize;
use serde_json::{to_string_pretty, Value}; use serde_json::{json, to_string_pretty, Value};
use test_utils::{find_mismatch, Fixture}; use test_utils::{find_mismatch, Fixture};
use vfs::AbsPathBuf; use vfs::AbsPathBuf;
@ -106,9 +103,12 @@ impl<'a> Project<'a> {
..Default::default() ..Default::default()
}), }),
window: Some(lsp_types::WindowClientCapabilities { window: Some(lsp_types::WindowClientCapabilities {
work_done_progress: Some(true), work_done_progress: Some(false),
..Default::default() ..Default::default()
}), }),
experimental: Some(json!({
"statusNotification": true,
})),
..Default::default() ..Default::default()
}, },
); );
@ -192,9 +192,6 @@ impl Server {
while let Some(msg) = self.recv().unwrap_or_else(|Timeout| panic!("timeout: {:?}", r)) { while let Some(msg) = self.recv().unwrap_or_else(|Timeout| panic!("timeout: {:?}", r)) {
match msg { match msg {
Message::Request(req) => { Message::Request(req) => {
if req.method == "window/workDoneProgress/create" {
continue;
}
if req.method == "client/registerCapability" { if req.method == "client/registerCapability" {
let params = req.params.to_string(); let params = req.params.to_string();
if ["workspace/didChangeWatchedFiles", "textDocument/didSave"] if ["workspace/didChangeWatchedFiles", "textDocument/didSave"]
@ -220,14 +217,13 @@ impl Server {
} }
pub(crate) fn wait_until_workspace_is_loaded(self) -> Server { pub(crate) fn wait_until_workspace_is_loaded(self) -> Server {
self.wait_for_message_cond(1, &|msg: &Message| match msg { self.wait_for_message_cond(1, &|msg: &Message| match msg {
Message::Notification(n) if n.method == "$/progress" => { Message::Notification(n) if n.method == "rust-analyzer/status" => {
match n.clone().extract::<ProgressParams>("$/progress").unwrap() { let status = n
ProgressParams { .clone()
token: lsp_types::ProgressToken::String(ref token), .extract::<lsp_ext::StatusParams>("rust-analyzer/status")
value: ProgressParamsValue::WorkDone(WorkDoneProgress::End(_)), .unwrap()
} if token == "rustAnalyzer/roots scanned" => true, .status;
_ => false, matches!(status, lsp_ext::Status::Ready)
}
} }
_ => false, _ => false,
}) })