Reduce logging in lsp tests

Max Brunsfeld created

Change summary

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(-)

Detailed changes

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",

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"

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();

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"