diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-14 12:13:58 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-14 12:13:58 +0100 |
commit | 735baad6cea6d8f317fc83f2f077cd7148dcb3d9 (patch) | |
tree | fc82048ad3ff5103f19fc27206e0fcf1353e17a6 /crates/ra_hir_ty/src/test_db.rs | |
parent | 510866b4a1a812414568bd96f1d197587ead78c0 (diff) | |
parent | b031899dac6ad5847cc2f5551766a567657f095d (diff) |
Merge #5368
5368: Compress match checking tests r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/test_db.rs')
-rw-r--r-- | crates/ra_hir_ty/src/test_db.rs | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index ddafd0ea1..fb8723fb7 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs | |||
@@ -82,7 +82,7 @@ impl FileLoader for TestDB { | |||
82 | } | 82 | } |
83 | 83 | ||
84 | impl TestDB { | 84 | impl TestDB { |
85 | pub fn module_for_file(&self, file_id: FileId) -> ModuleId { | 85 | pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId { |
86 | for &krate in self.relevant_crates(file_id).iter() { | 86 | for &krate in self.relevant_crates(file_id).iter() { |
87 | let crate_def_map = self.crate_def_map(krate); | 87 | let crate_def_map = self.crate_def_map(krate); |
88 | for (local_id, data) in crate_def_map.modules.iter() { | 88 | for (local_id, data) in crate_def_map.modules.iter() { |
@@ -94,7 +94,7 @@ impl TestDB { | |||
94 | panic!("Can't find module for file") | 94 | panic!("Can't find module for file") |
95 | } | 95 | } |
96 | 96 | ||
97 | fn diag<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) { | 97 | pub(crate) fn diag<F: FnMut(&dyn Diagnostic)>(&self, mut cb: F) { |
98 | let crate_graph = self.crate_graph(); | 98 | let crate_graph = self.crate_graph(); |
99 | for krate in crate_graph.iter() { | 99 | for krate in crate_graph.iter() { |
100 | let crate_def_map = self.crate_def_map(krate); | 100 | let crate_def_map = self.crate_def_map(krate); |
@@ -124,7 +124,7 @@ impl TestDB { | |||
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | pub fn diagnostics(&self) -> (String, u32) { | 127 | pub(crate) fn diagnostics(&self) -> (String, u32) { |
128 | let mut buf = String::new(); | 128 | let mut buf = String::new(); |
129 | let mut count = 0; | 129 | let mut count = 0; |
130 | self.diag(|d| { | 130 | self.diag(|d| { |
@@ -134,22 +134,7 @@ impl TestDB { | |||
134 | (buf, count) | 134 | (buf, count) |
135 | } | 135 | } |
136 | 136 | ||
137 | /// Like `diagnostics`, but filtered for a single diagnostic. | 137 | pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> { |
138 | pub fn diagnostic<D: Diagnostic>(&self) -> (String, u32) { | ||
139 | let mut buf = String::new(); | ||
140 | let mut count = 0; | ||
141 | self.diag(|d| { | ||
142 | // We want to filter diagnostics by the particular one we are testing for, to | ||
143 | // avoid surprising results in tests. | ||
144 | if d.downcast_ref::<D>().is_some() { | ||
145 | format_to!(buf, "{:?}: {}\n", d.syntax_node(self).text(), d.message()); | ||
146 | count += 1; | ||
147 | }; | ||
148 | }); | ||
149 | (buf, count) | ||
150 | } | ||
151 | |||
152 | pub fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> { | ||
153 | let mut files = Vec::new(); | 138 | let mut files = Vec::new(); |
154 | let crate_graph = self.crate_graph(); | 139 | let crate_graph = self.crate_graph(); |
155 | for krate in crate_graph.iter() { | 140 | for krate in crate_graph.iter() { |