diff options
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r-- | crates/hir_ty/src/tests.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs index c953925ec..91c9d38c5 100644 --- a/crates/hir_ty/src/tests.rs +++ b/crates/hir_ty/src/tests.rs | |||
@@ -8,7 +8,7 @@ mod method_resolution; | |||
8 | mod macros; | 8 | mod macros; |
9 | mod display_source_code; | 9 | mod display_source_code; |
10 | 10 | ||
11 | use std::sync::Arc; | 11 | use std::{env, sync::Arc}; |
12 | 12 | ||
13 | use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; | 13 | use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; |
14 | use expect::Expect; | 14 | use expect::Expect; |
@@ -22,12 +22,14 @@ use hir_def::{ | |||
22 | AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, | 22 | AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, |
23 | }; | 23 | }; |
24 | use hir_expand::{db::AstDatabase, InFile}; | 24 | use hir_expand::{db::AstDatabase, InFile}; |
25 | use stdx::format_to; | 25 | use stdx::{format_to, RacyFlag}; |
26 | use syntax::{ | 26 | use syntax::{ |
27 | algo, | 27 | algo, |
28 | ast::{self, AstNode}, | 28 | ast::{self, AstNode}, |
29 | SyntaxNode, | 29 | SyntaxNode, |
30 | }; | 30 | }; |
31 | use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; | ||
32 | use tracing_tree::HierarchicalLayer; | ||
31 | 33 | ||
32 | use crate::{ | 34 | use crate::{ |
33 | db::HirDatabase, display::HirDisplay, infer::TypeMismatch, test_db::TestDB, InferenceResult, Ty, | 35 | db::HirDatabase, display::HirDisplay, infer::TypeMismatch, test_db::TestDB, InferenceResult, Ty, |
@@ -37,9 +39,12 @@ use crate::{ | |||
37 | // against snapshots of the expected results using expect. Use | 39 | // against snapshots of the expected results using expect. Use |
38 | // `env UPDATE_EXPECT=1 cargo test -p hir_ty` to update the snapshots. | 40 | // `env UPDATE_EXPECT=1 cargo test -p hir_ty` to update the snapshots. |
39 | 41 | ||
40 | fn setup_tracing() -> tracing::subscriber::DefaultGuard { | 42 | fn setup_tracing() -> Option<tracing::subscriber::DefaultGuard> { |
41 | use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; | 43 | static ENABLE: RacyFlag = RacyFlag::new(); |
42 | use tracing_tree::HierarchicalLayer; | 44 | if !ENABLE.get(|| env::var("CHALK_DEBUG").is_ok()) { |
45 | return None; | ||
46 | } | ||
47 | |||
43 | let filter = EnvFilter::from_env("CHALK_DEBUG"); | 48 | let filter = EnvFilter::from_env("CHALK_DEBUG"); |
44 | let layer = HierarchicalLayer::default() | 49 | let layer = HierarchicalLayer::default() |
45 | .with_indent_lines(true) | 50 | .with_indent_lines(true) |
@@ -47,7 +52,7 @@ fn setup_tracing() -> tracing::subscriber::DefaultGuard { | |||
47 | .with_indent_amount(2) | 52 | .with_indent_amount(2) |
48 | .with_writer(std::io::stderr); | 53 | .with_writer(std::io::stderr); |
49 | let subscriber = Registry::default().with(filter).with(layer); | 54 | let subscriber = Registry::default().with(filter).with(layer); |
50 | tracing::subscriber::set_default(subscriber) | 55 | Some(tracing::subscriber::set_default(subscriber)) |
51 | } | 56 | } |
52 | 57 | ||
53 | fn check_types(ra_fixture: &str) { | 58 | fn check_types(ra_fixture: &str) { |