From 41e9071ce554784ca4785ba263a4fd0452790a00 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Wed, 30 Jul 2025 09:44:19 -0700 Subject: [PATCH] refactor: move query test fixtures into their own dir --- src/handlers/diagnostic.rs | 4 +-- src/handlers/formatting.rs | 24 +++++++------- src/handlers/workspace_symbol.rs | 4 +-- src/test_helpers.rs | 10 +++--- .../fixtures}/example_test_files/complex.scm | 0 .../fixtures}/example_test_files/simple.scm | 0 .../formatting_test_files/after_complex.scm | 0 .../formatting_test_files/after_missing.scm | 0 .../after_predicates.scm | 0 .../after_syntax_error.scm | 0 .../after_trailing_whitespace.scm | 0 .../formatting_test_files/before_complex.scm | 0 .../formatting_test_files/before_missing.scm | 0 .../before_predicates.scm | 0 .../before_syntax_error.scm | 0 .../before_trailing_whitespace.scm | 0 .../test_workspace/queries/cpp/folds.scm | 0 .../test_workspace/queries/cpp/test.scm | 0 .../queries/other/highlights.scm | 0 .../test_workspace/queries/other/test.scm | 0 tests/format.rs | 32 +++++++++---------- tests/lint.rs | 10 +++--- 22 files changed, 42 insertions(+), 42 deletions(-) rename {queries => tests/fixtures}/example_test_files/complex.scm (100%) rename {queries => tests/fixtures}/example_test_files/simple.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/after_complex.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/after_missing.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/after_predicates.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/after_syntax_error.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/after_trailing_whitespace.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/before_complex.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/before_missing.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/before_predicates.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/before_syntax_error.scm (100%) rename {queries => tests/fixtures}/formatting_test_files/before_trailing_whitespace.scm (100%) rename {queries => tests/fixtures}/test_workspace/queries/cpp/folds.scm (100%) rename {queries => tests/fixtures}/test_workspace/queries/cpp/test.scm (100%) rename {queries => tests/fixtures}/test_workspace/queries/other/highlights.scm (100%) rename {queries => tests/fixtures}/test_workspace/queries/other/test.scm (100%) diff --git a/src/handlers/diagnostic.rs b/src/handlers/diagnostic.rs index 243ca08..f761f67 100644 --- a/src/handlers/diagnostic.rs +++ b/src/handlers/diagnostic.rs @@ -1022,14 +1022,14 @@ mod test { static CPP_FILE_URI: LazyLock = LazyLock::new(|| { Url::from_file_path(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/test_workspace/queries/cpp/test.scm" + "/tests/fixtures/test_workspace/queries/cpp/test.scm" )) .unwrap() }); static OTHER_FILE_URI: LazyLock = LazyLock::new(|| { Url::from_file_path(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/test_workspace/queries/other/test.scm" + "/tests/fixtures/test_workspace/queries/other/test.scm" )) .unwrap() }); diff --git a/src/handlers/formatting.rs b/src/handlers/formatting.rs index 5db48c8..17bc29d 100644 --- a/src/handlers/formatting.rs +++ b/src/handlers/formatting.rs @@ -357,24 +357,24 @@ mod test { #[rstest] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_trailing_whitespace.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_trailing_whitespace.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_trailing_whitespace.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_trailing_whitespace.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_predicates.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_predicates.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_predicates.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_predicates.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_missing.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_missing.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_missing.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_missing.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_syntax_error.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_syntax_error.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_syntax_error.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_syntax_error.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_complex.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_complex.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_complex.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_complex.scm")), )] #[tokio::test(flavor = "current_thread")] async fn server_formatting(#[case] before: &str, #[case] after: &str) { @@ -422,8 +422,8 @@ mod test { #[rstest] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_syntax_error.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_syntax_error.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_syntax_error.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_syntax_error.scm")), Range::new(Position::new(0, 0), Position::new(1, 0)), )] #[case( diff --git a/src/handlers/workspace_symbol.rs b/src/handlers/workspace_symbol.rs index 3777437..286c409 100644 --- a/src/handlers/workspace_symbol.rs +++ b/src/handlers/workspace_symbol.rs @@ -97,12 +97,12 @@ mod test { // Assert let cpp_folds_uri = Url::from_file_path(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/test_workspace/queries/cpp/folds.scm" + "/tests/fixtures/test_workspace/queries/cpp/folds.scm" )) .unwrap(); let other_highlights_uri = Url::from_file_path(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/test_workspace/queries/other/highlights.scm" + "/tests/fixtures/test_workspace/queries/other/highlights.scm" )) .unwrap(); #[allow(deprecated)] diff --git a/src/test_helpers.rs b/src/test_helpers.rs index c6a8b28..c473fef 100644 --- a/src/test_helpers.rs +++ b/src/test_helpers.rs @@ -25,24 +25,24 @@ pub mod helpers { pub static CPP_HIGHLIGHTS_WS_URI: LazyLock = LazyLock::new(|| { Url::from_file_path(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/test_workspace/queries/cpp/test.scm" + "/tests/fixtures/test_workspace/queries/cpp/test.scm" )) .unwrap() }); pub static FOO_HIGHLIGHTS_WS_URI: LazyLock = LazyLock::new(|| { Url::from_file_path(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/test_workspace/queries/foo/test.scm" + "/tests/fixtures/test_workspace/queries/foo/test.scm" )) .unwrap() }); pub const SIMPLE_FILE: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/example_test_files/simple.scm" + "/tests/fixtures/example_test_files/simple.scm" )); pub const COMPLEX_FILE: &str = include_str!(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/example_test_files/complex.scm" + "/tests/fixtures/example_test_files/complex.scm" )); pub static TEST_CLIENT_CAPABILITIES: LazyLock = @@ -88,7 +88,7 @@ pub mod helpers { name: String::from("test_workspace"), uri: Url::from_file_path(concat!( env!("CARGO_MANIFEST_DIR"), - "/queries/test_workspace/" + "/tests/fixtures/test_workspace/" )) .unwrap(), }]), diff --git a/queries/example_test_files/complex.scm b/tests/fixtures/example_test_files/complex.scm similarity index 100% rename from queries/example_test_files/complex.scm rename to tests/fixtures/example_test_files/complex.scm diff --git a/queries/example_test_files/simple.scm b/tests/fixtures/example_test_files/simple.scm similarity index 100% rename from queries/example_test_files/simple.scm rename to tests/fixtures/example_test_files/simple.scm diff --git a/queries/formatting_test_files/after_complex.scm b/tests/fixtures/formatting_test_files/after_complex.scm similarity index 100% rename from queries/formatting_test_files/after_complex.scm rename to tests/fixtures/formatting_test_files/after_complex.scm diff --git a/queries/formatting_test_files/after_missing.scm b/tests/fixtures/formatting_test_files/after_missing.scm similarity index 100% rename from queries/formatting_test_files/after_missing.scm rename to tests/fixtures/formatting_test_files/after_missing.scm diff --git a/queries/formatting_test_files/after_predicates.scm b/tests/fixtures/formatting_test_files/after_predicates.scm similarity index 100% rename from queries/formatting_test_files/after_predicates.scm rename to tests/fixtures/formatting_test_files/after_predicates.scm diff --git a/queries/formatting_test_files/after_syntax_error.scm b/tests/fixtures/formatting_test_files/after_syntax_error.scm similarity index 100% rename from queries/formatting_test_files/after_syntax_error.scm rename to tests/fixtures/formatting_test_files/after_syntax_error.scm diff --git a/queries/formatting_test_files/after_trailing_whitespace.scm b/tests/fixtures/formatting_test_files/after_trailing_whitespace.scm similarity index 100% rename from queries/formatting_test_files/after_trailing_whitespace.scm rename to tests/fixtures/formatting_test_files/after_trailing_whitespace.scm diff --git a/queries/formatting_test_files/before_complex.scm b/tests/fixtures/formatting_test_files/before_complex.scm similarity index 100% rename from queries/formatting_test_files/before_complex.scm rename to tests/fixtures/formatting_test_files/before_complex.scm diff --git a/queries/formatting_test_files/before_missing.scm b/tests/fixtures/formatting_test_files/before_missing.scm similarity index 100% rename from queries/formatting_test_files/before_missing.scm rename to tests/fixtures/formatting_test_files/before_missing.scm diff --git a/queries/formatting_test_files/before_predicates.scm b/tests/fixtures/formatting_test_files/before_predicates.scm similarity index 100% rename from queries/formatting_test_files/before_predicates.scm rename to tests/fixtures/formatting_test_files/before_predicates.scm diff --git a/queries/formatting_test_files/before_syntax_error.scm b/tests/fixtures/formatting_test_files/before_syntax_error.scm similarity index 100% rename from queries/formatting_test_files/before_syntax_error.scm rename to tests/fixtures/formatting_test_files/before_syntax_error.scm diff --git a/queries/formatting_test_files/before_trailing_whitespace.scm b/tests/fixtures/formatting_test_files/before_trailing_whitespace.scm similarity index 100% rename from queries/formatting_test_files/before_trailing_whitespace.scm rename to tests/fixtures/formatting_test_files/before_trailing_whitespace.scm diff --git a/queries/test_workspace/queries/cpp/folds.scm b/tests/fixtures/test_workspace/queries/cpp/folds.scm similarity index 100% rename from queries/test_workspace/queries/cpp/folds.scm rename to tests/fixtures/test_workspace/queries/cpp/folds.scm diff --git a/queries/test_workspace/queries/cpp/test.scm b/tests/fixtures/test_workspace/queries/cpp/test.scm similarity index 100% rename from queries/test_workspace/queries/cpp/test.scm rename to tests/fixtures/test_workspace/queries/cpp/test.scm diff --git a/queries/test_workspace/queries/other/highlights.scm b/tests/fixtures/test_workspace/queries/other/highlights.scm similarity index 100% rename from queries/test_workspace/queries/other/highlights.scm rename to tests/fixtures/test_workspace/queries/other/highlights.scm diff --git a/queries/test_workspace/queries/other/test.scm b/tests/fixtures/test_workspace/queries/other/test.scm similarity index 100% rename from queries/test_workspace/queries/other/test.scm rename to tests/fixtures/test_workspace/queries/other/test.scm diff --git a/tests/format.rs b/tests/format.rs index f784751..a2bddc5 100644 --- a/tests/format.rs +++ b/tests/format.rs @@ -5,24 +5,24 @@ mod test { #[rstest] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_trailing_whitespace.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_trailing_whitespace.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_trailing_whitespace.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_trailing_whitespace.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_predicates.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_predicates.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_predicates.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_predicates.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_missing.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_missing.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_missing.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_missing.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_syntax_error.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_syntax_error.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_syntax_error.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_syntax_error.scm")), )] #[case( - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_complex.scm")), - include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_complex.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_complex.scm")), + include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_complex.scm")), )] fn cli_format_write(#[context] ctx: Context, #[case] before: &str, #[case] after: &str) { // Arrange @@ -54,27 +54,27 @@ mod test { #[rstest] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_trailing_whitespace.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_trailing_whitespace.scm"), FormatValidity::Invalid )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_trailing_whitespace.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_trailing_whitespace.scm"), FormatValidity::Valid )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_predicates.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_predicates.scm"), FormatValidity::Invalid )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_missing.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_missing.scm"), FormatValidity::Invalid )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_syntax_error.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_syntax_error.scm"), FormatValidity::SyntaxError // NOTE: Files containing syntax errors cannot be formatted )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_complex.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_complex.scm"), FormatValidity::Valid )] fn cli_format_validate(#[case] path_str: &str, #[case] valid: FormatValidity) { diff --git a/tests/lint.rs b/tests/lint.rs index 4e44d0c..b369e37 100644 --- a/tests/lint.rs +++ b/tests/lint.rs @@ -51,23 +51,23 @@ mod test { #[rstest] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/after_trailing_whitespace.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/after_trailing_whitespace.scm"), Some(["Invalid capture name \"@cap\" (fix available)"].as_slice()) )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_predicates.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_predicates.scm"), Some(["Unrecognized predicate \"lua-match\""].as_slice()) )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_missing.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_missing.scm"), Some(["This pattern has no captures, and will not be processed"].as_slice()) )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/formatting_test_files/before_syntax_error.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/formatting_test_files/before_syntax_error.scm"), Some(["Invalid syntax"].as_slice()) )] #[case( - concat!(env!("CARGO_MANIFEST_DIR"), "/queries/example_test_files/simple.scm"), + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures/example_test_files/simple.scm"), None )] fn cli_lint(#[case] path_str: &str, #[case] warning_messages: Option<&[&str]>) {