diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 1dcec47b4..6ec084a59 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -1366,16 +1366,20 @@ impl Test { self.json_summary, )?; test_summary.test_num = 1; + } else { + warn!("Test corpus not found at {}", test_corpus_dir.display()); } // Check that all of the queries are valid. let query_dir = current_dir.join("queries"); - check_test( - test::check_queries_at_path(language, &query_dir), - &test_summary, - self.json_summary, - )?; - test_summary.test_num = 1; + if query_dir.is_dir() { + check_test( + test::check_queries_at_path(language, &query_dir), + &test_summary, + self.json_summary, + )?; + test_summary.test_num = 1; + } // Run the syntax highlighting tests. let test_highlight_dir = test_dir.join("highlight"); diff --git a/crates/cli/src/test.rs b/crates/cli/src/test.rs index 386497b42..e05fbc915 100644 --- a/crates/cli/src/test.rs +++ b/crates/cli/src/test.rs @@ -683,22 +683,20 @@ pub fn run_tests_at_path( } pub fn check_queries_at_path(language: &Language, path: &Path) -> Result<()> { - if path.exists() { - for entry in WalkDir::new(path) - .into_iter() - .filter_map(std::result::Result::ok) - .filter(|e| { - e.file_type().is_file() - && e.path().extension().and_then(OsStr::to_str) == Some("scm") - && !e.path().starts_with(".") - }) - { - let filepath = entry.file_name().to_str().unwrap_or(""); - let content = fs::read_to_string(entry.path()) - .with_context(|| format!("Error reading query file {filepath:?}"))?; - Query::new(language, &content) - .with_context(|| format!("Error in query file {filepath:?}"))?; - } + for entry in WalkDir::new(path) + .into_iter() + .filter_map(std::result::Result::ok) + .filter(|e| { + e.file_type().is_file() + && e.path().extension().and_then(OsStr::to_str) == Some("scm") + && !e.path().starts_with(".") + }) + { + let filepath = entry.file_name().to_str().unwrap_or(""); + let content = fs::read_to_string(entry.path()) + .with_context(|| format!("Error reading query file {filepath:?}"))?; + Query::new(language, &content) + .with_context(|| format!("Error in query file {filepath:?}"))?; } Ok(()) }