Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/tests.rs')
-rw-r--r--crates/ide-diagnostics/src/tests.rs36
1 files changed, 35 insertions, 1 deletions
diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs
index afa641c733..b5cd4e0d68 100644
--- a/crates/ide-diagnostics/src/tests.rs
+++ b/crates/ide-diagnostics/src/tests.rs
@@ -8,7 +8,7 @@ use ide_db::{
RootDatabase,
};
use stdx::trim_indent;
-use test_utils::{assert_eq_text, extract_annotations};
+use test_utils::{assert_eq_text, extract_annotations, MiniCore};
use crate::{DiagnosticsConfig, ExprFillDefaultMode, Severity};
@@ -121,6 +121,15 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
})
.collect::<Vec<_>>();
actual.sort_by_key(|(range, _)| range.start());
+ if expected.is_empty() {
+ // makes minicore smoke test debugable
+ for (e, _) in &actual {
+ eprintln!(
+ "Code in range {e:?} = {}",
+ &db.file_text(file_id)[usize::from(e.start())..usize::from(e.end())]
+ )
+ }
+ }
assert_eq!(expected, actual);
}
}
@@ -143,3 +152,28 @@ fn test_disabled_diagnostics() {
);
assert!(!diagnostics.is_empty());
}
+
+#[test]
+fn minicore_smoke_test() {
+ fn check(minicore: MiniCore) {
+ let source = minicore.source_code();
+ let mut config = DiagnosticsConfig::test_sample();
+ // This should be ignored since we conditionaly remove code which creates single item use with braces
+ config.disabled.insert("unnecessary-braces".to_string());
+ check_diagnostics_with_config(config, &source);
+ }
+
+ // Checks that there is no diagnostic in minicore for each flag.
+ for flag in MiniCore::available_flags() {
+ if flag == "clone" {
+ // Clone without copy has `moved-out-of-ref`, so ignoring.
+ // FIXME: Maybe we should merge copy and clone in a single flag?
+ continue;
+ }
+ eprintln!("Checking minicore flag {flag}");
+ check(MiniCore::from_flags([flag]));
+ }
+ // And one time for all flags, to check codes which are behind multiple flags + prevent name collisions
+ eprintln!("Checking all minicore flags");
+ check(MiniCore::from_flags(MiniCore::available_flags()))
+}