mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:26:23 -04:00
fix(cli): display warning to user if parser test corpus dir isn't found
This commit is contained in:
parent
0617a59ed6
commit
d9acc99734
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue