mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Compress match checking tests
This commit is contained in:
parent
af6984f6a6
commit
b031899dac
3 changed files with 452 additions and 1201 deletions
|
@ -261,8 +261,11 @@ fn check_diagnostics(ra_fixture: &str) {
|
|||
// FXIME: macros...
|
||||
let file_id = d.source().file_id.original_file(&db);
|
||||
let range = d.syntax_node(&db).text_range();
|
||||
actual.entry(file_id).or_default().push((range, d.message().to_owned()));
|
||||
// FIXME: support multi-line messages in annotations
|
||||
let message = d.message().lines().next().unwrap().to_owned();
|
||||
actual.entry(file_id).or_default().push((range, message));
|
||||
});
|
||||
actual.values_mut().for_each(|diags| diags.sort_by_key(|it| it.0.start()));
|
||||
|
||||
assert_eq!(annotations, actual);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -82,7 +82,7 @@ impl FileLoader for TestDB {
|
|||
}
|
||||
|
||||
impl TestDB {
|
||||
pub fn module_for_file(&self, file_id: FileId) -> ModuleId {
|
||||
pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId {
|
||||
for &krate in self.relevant_crates(file_id).iter() {
|
||||
let crate_def_map = self.crate_def_map(krate);
|
||||
for (local_id, data) in crate_def_map.modules.iter() {
|
||||
|
@ -124,7 +124,7 @@ impl TestDB {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn diagnostics(&self) -> (String, u32) {
|
||||
pub(crate) fn diagnostics(&self) -> (String, u32) {
|
||||
let mut buf = String::new();
|
||||
let mut count = 0;
|
||||
self.diag(|d| {
|
||||
|
@ -134,22 +134,7 @@ impl TestDB {
|
|||
(buf, count)
|
||||
}
|
||||
|
||||
/// Like `diagnostics`, but filtered for a single diagnostic.
|
||||
pub fn diagnostic<D: Diagnostic>(&self) -> (String, u32) {
|
||||
let mut buf = String::new();
|
||||
let mut count = 0;
|
||||
self.diag(|d| {
|
||||
// We want to filter diagnostics by the particular one we are testing for, to
|
||||
// avoid surprising results in tests.
|
||||
if d.downcast_ref::<D>().is_some() {
|
||||
format_to!(buf, "{:?}: {}\n", d.syntax_node(self).text(), d.message());
|
||||
count += 1;
|
||||
};
|
||||
});
|
||||
(buf, count)
|
||||
}
|
||||
|
||||
pub fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> {
|
||||
pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> {
|
||||
let mut files = Vec::new();
|
||||
let crate_graph = self.crate_graph();
|
||||
for krate in crate_graph.iter() {
|
||||
|
|
Loading…
Reference in a new issue