From 8d6504826c89fb1a50f7f4501200894188b0d12b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 11 Feb 2022 16:37:50 -0800 Subject: [PATCH] Reduce logging in lsp tests --- Cargo.lock | 4 ++-- crates/lsp/Cargo.toml | 3 ++- crates/lsp/src/lsp.rs | 10 +++++++--- crates/project/Cargo.toml | 1 - 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e9d43b2c0..4165643656 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2776,6 +2776,8 @@ version = "0.1.0" dependencies = [ "anyhow", "async-pipe", + "ctor", + "env_logger", "futures", "gpui", "log", @@ -2784,7 +2786,6 @@ dependencies = [ "postage", "serde", "serde_json", - "simplelog", "smol", "unindent", "util", @@ -3523,7 +3524,6 @@ dependencies = [ "rpc", "serde", "serde_json", - "simplelog", "smol", "sum_tree", "tempdir", diff --git a/crates/lsp/Cargo.toml b/crates/lsp/Cargo.toml index 3d453054f8..fca48970d2 100644 --- a/crates/lsp/Cargo.toml +++ b/crates/lsp/Cargo.toml @@ -27,5 +27,6 @@ smol = "1.2" gpui = { path = "../gpui", features = ["test-support"] } util = { path = "../util", features = ["test-support"] } async-pipe = { git = "https://github.com/routerify/async-pipe-rs", rev = "feeb77e83142a9ff837d0767652ae41bfc5d8e47" } -simplelog = "0.9" +ctor = "0.1" +env_logger = "0.8" unindent = "0.1.7" diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index 3a27b8f98b..73f4fe698b 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -707,10 +707,16 @@ impl FakeLanguageServer { mod tests { use super::*; use gpui::TestAppContext; - use simplelog::SimpleLogger; use unindent::Unindent; use util::test::temp_tree; + #[ctor::ctor] + fn init_logger() { + if std::env::var("RUST_LOG").is_ok() { + env_logger::init(); + } + } + #[gpui::test] async fn test_rust_analyzer(cx: TestAppContext) { let lib_source = r#" @@ -771,8 +777,6 @@ mod tests { #[gpui::test] async fn test_fake(cx: TestAppContext) { - SimpleLogger::init(log::LevelFilter::Info, Default::default()).unwrap(); - let (server, mut fake) = LanguageServer::fake(&cx).await; let (message_tx, message_rx) = channel::unbounded(); diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.toml index 3cc9a45923..1130282e0e 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -49,6 +49,5 @@ lsp = { path = "../lsp", features = ["test-support"] } util = { path = "../util", features = ["test-support"] } rpc = { path = "../rpc", features = ["test-support"] } rand = "0.8.3" -simplelog = "0.9" tempdir = { version = "0.3.7" } unindent = "0.1.7"