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.rs55
1 files changed, 41 insertions, 14 deletions
diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs
index ec74640a54..fc2a7db717 100644
--- a/crates/ide-diagnostics/src/tests.rs
+++ b/crates/ide-diagnostics/src/tests.rs
@@ -1,5 +1,7 @@
#![allow(clippy::print_stderr)]
+mod overly_long_real_world_cases;
+
use ide_db::{
assists::AssistResolveStrategy, base_db::SourceDatabase, LineIndexDatabase, RootDatabase,
};
@@ -16,7 +18,10 @@ use crate::{DiagnosticsConfig, ExprFillDefaultMode, Severity};
/// * the first diagnostic fix trigger range touches the input cursor position
/// * that the contents of the file containing the cursor match `after` after the diagnostic fix is applied
#[track_caller]
-pub(crate) fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
+pub(crate) fn check_fix(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
check_nth_fix(0, ra_fixture_before, ra_fixture_after);
}
/// Takes a multi-file input fixture with annotated cursor positions,
@@ -24,14 +29,21 @@ pub(crate) fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
/// * a diagnostic is produced
/// * every diagnostic fixes trigger range touches the input cursor position
/// * that the contents of the file containing the cursor match `after` after each diagnostic fix is applied
-pub(crate) fn check_fixes(ra_fixture_before: &str, ra_fixtures_after: Vec<&str>) {
+pub(crate) fn check_fixes(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ ra_fixtures_after: Vec<&str>,
+) {
for (i, ra_fixture_after) in ra_fixtures_after.iter().enumerate() {
check_nth_fix(i, ra_fixture_before, ra_fixture_after)
}
}
#[track_caller]
-fn check_nth_fix(nth: usize, ra_fixture_before: &str, ra_fixture_after: &str) {
+fn check_nth_fix(
+ nth: usize,
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
let mut config = DiagnosticsConfig::test_sample();
config.expr_fill_default = ExprFillDefaultMode::Default;
check_nth_fix_with_config(config, nth, ra_fixture_before, ra_fixture_after)
@@ -39,8 +51,8 @@ fn check_nth_fix(nth: usize, ra_fixture_before: &str, ra_fixture_after: &str) {
#[track_caller]
pub(crate) fn check_fix_with_disabled(
- ra_fixture_before: &str,
- ra_fixture_after: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
disabled: impl Iterator<Item = String>,
) {
let mut config = DiagnosticsConfig::test_sample();
@@ -53,8 +65,8 @@ pub(crate) fn check_fix_with_disabled(
fn check_nth_fix_with_config(
config: DiagnosticsConfig,
nth: usize,
- ra_fixture_before: &str,
- ra_fixture_after: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
) {
let after = trim_indent(ra_fixture_after);
@@ -93,14 +105,20 @@ fn check_nth_fix_with_config(
assert_eq_text!(&after, &actual);
}
-pub(crate) fn check_fixes_unordered(ra_fixture_before: &str, ra_fixtures_after: Vec<&str>) {
+pub(crate) fn check_fixes_unordered(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ ra_fixtures_after: Vec<&str>,
+) {
for ra_fixture_after in ra_fixtures_after.iter() {
check_has_fix(ra_fixture_before, ra_fixture_after)
}
}
#[track_caller]
-pub(crate) fn check_has_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
+pub(crate) fn check_has_fix(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
let after = trim_indent(ra_fixture_after);
let (db, file_position) = RootDatabase::with_position(ra_fixture_before);
@@ -143,7 +161,10 @@ pub(crate) fn check_has_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
}
#[track_caller]
-pub(crate) fn check_has_single_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
+pub(crate) fn check_has_single_fix(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
let after = trim_indent(ra_fixture_after);
let (db, file_position) = RootDatabase::with_position(ra_fixture_before);
@@ -189,7 +210,7 @@ pub(crate) fn check_has_single_fix(ra_fixture_before: &str, ra_fixture_after: &s
}
/// Checks that there's a diagnostic *without* fix at `$0`.
-pub(crate) fn check_no_fix(ra_fixture: &str) {
+pub(crate) fn check_no_fix(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
let (db, file_position) = RootDatabase::with_position(ra_fixture);
let diagnostic = super::full_diagnostics(
&db,
@@ -203,21 +224,27 @@ pub(crate) fn check_no_fix(ra_fixture: &str) {
}
#[track_caller]
-pub(crate) fn check_diagnostics(ra_fixture: &str) {
+pub(crate) fn check_diagnostics(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
let mut config = DiagnosticsConfig::test_sample();
config.disabled.insert("inactive-code".to_owned());
check_diagnostics_with_config(config, ra_fixture)
}
#[track_caller]
-pub(crate) fn check_diagnostics_with_disabled(ra_fixture: &str, disabled: &[&str]) {
+pub(crate) fn check_diagnostics_with_disabled(
+ #[rust_analyzer::rust_fixture] ra_fixture: &str,
+ disabled: &[&str],
+) {
let mut config = DiagnosticsConfig::test_sample();
config.disabled.extend(disabled.iter().map(|&s| s.to_owned()));
check_diagnostics_with_config(config, ra_fixture)
}
#[track_caller]
-pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixture: &str) {
+pub(crate) fn check_diagnostics_with_config(
+ config: DiagnosticsConfig,
+ #[rust_analyzer::rust_fixture] ra_fixture: &str,
+) {
let (db, files) = RootDatabase::with_many_files(ra_fixture);
let mut annotations = files
.iter()