aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-18 16:20:10 +0100
committerAleksey Kladov <[email protected]>2020-08-18 16:20:57 +0100
commitaad911fb0cd772e809270be3e0a526d4738b9dd5 (patch)
tree071693ea923db713b5e590a5e7cecfa2fff04185 /crates/hir_ty
parente81c310b6224946318b8e6af56a55021716ea9b5 (diff)
Speedup ty tests
Closes #5792
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/tests.rs17
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;
8mod macros; 8mod macros;
9mod display_source_code; 9mod display_source_code;
10 10
11use std::sync::Arc; 11use std::{env, sync::Arc};
12 12
13use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; 13use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt};
14use expect::Expect; 14use expect::Expect;
@@ -22,12 +22,14 @@ use hir_def::{
22 AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, 22 AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId,
23}; 23};
24use hir_expand::{db::AstDatabase, InFile}; 24use hir_expand::{db::AstDatabase, InFile};
25use stdx::format_to; 25use stdx::{format_to, RacyFlag};
26use syntax::{ 26use syntax::{
27 algo, 27 algo,
28 ast::{self, AstNode}, 28 ast::{self, AstNode},
29 SyntaxNode, 29 SyntaxNode,
30}; 30};
31use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
32use tracing_tree::HierarchicalLayer;
31 33
32use crate::{ 34use 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
40fn setup_tracing() -> tracing::subscriber::DefaultGuard { 42fn 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
53fn check_types(ra_fixture: &str) { 58fn check_types(ra_fixture: &str) {