From fe786f33666ef8a63d8ab3e9c30e328c31a79c91 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 12 Nov 2021 17:01:57 +0100 Subject: [PATCH] Init `env_logger` in the `editor` crate for tests only --- Cargo.lock | 2 ++ crates/editor/Cargo.toml | 2 ++ crates/editor/src/test.rs | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 3d70d53b05eddc194203581b3bbbcb28d5ab4531..64f13c6540885c6b027658d121a65202a9ba6437 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1622,6 +1622,8 @@ dependencies = [ "anyhow", "buffer", "clock", + "ctor", + "env_logger", "gpui", "language", "lazy_static", diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index 59ed90d460558efcfdb9c478342144ca123e66f8..7f5ffec97ee79f7bb5761feb521ef80fefc7e26c 100644 --- a/crates/editor/Cargo.toml +++ b/crates/editor/Cargo.toml @@ -31,6 +31,8 @@ smol = "1.2" buffer = { path = "../buffer", features = ["test-support"] } language = { path = "../language", features = ["test-support"] } gpui = { path = "../gpui", features = ["test-support"] } +ctor = "0.1" +env_logger = "0.8" rand = "0.8" unindent = "0.1.7" tree-sitter = "0.19" diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rs index 97e7f5a08c23d193afa88c17dd8bd7019f0c30bc..33fafc3f54c4ecb2b7011f4ebf2783f97698c999 100644 --- a/crates/editor/src/test.rs +++ b/crates/editor/src/test.rs @@ -2,6 +2,12 @@ use gpui::{Entity, ModelHandle}; use smol::channel; use std::marker::PhantomData; +#[cfg(test)] +#[ctor::ctor] +fn init_logger() { + env_logger::init(); +} + pub fn sample_text(rows: usize, cols: usize) -> String { let mut text = String::new(); for row in 0..rows {