refactor: move query test fixtures into their own dir

This commit is contained in:
Riley Bruins 2025-07-30 09:44:19 -07:00
parent 3cc629b2b9
commit 41e9071ce5
22 changed files with 42 additions and 42 deletions

View file

@ -1022,14 +1022,14 @@ mod test {
static CPP_FILE_URI: LazyLock<Url> = 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<Url> = 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()
});

View file

@ -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(

View file

@ -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)]

View file

@ -25,24 +25,24 @@ pub mod helpers {
pub static CPP_HIGHLIGHTS_WS_URI: LazyLock<Url> = 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<Url> = 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<ClientCapabilities> =
@ -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(),
}]),

View file

@ -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) {

View file

@ -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]>) {