cli: Check queries when running tree-sitter test
This commit is contained in:
parent
b73b31356d
commit
e14e285a10
6 changed files with 69 additions and 20 deletions
|
|
@ -10,7 +10,7 @@ use std::fs;
|
|||
use std::io::{self, Write};
|
||||
use std::path::Path;
|
||||
use std::str;
|
||||
use tree_sitter::{Language, LogType, Parser};
|
||||
use tree_sitter::{Language, LogType, Parser, Query};
|
||||
|
||||
lazy_static! {
|
||||
static ref HEADER_REGEX: ByteRegex = ByteRegexBuilder::new(r"^===+\r?\n([^=]*)\r?\n===+\r?\n")
|
||||
|
|
@ -98,6 +98,22 @@ pub fn run_tests_at_path(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn check_queries_at_path(language: Language, path: &Path) -> Result<()> {
|
||||
for entry in fs::read_dir(path)? {
|
||||
let entry = entry?;
|
||||
let hidden = entry.file_name().to_str().unwrap_or("").starts_with(".");
|
||||
if !hidden {
|
||||
let content = fs::read_to_string(entry.path()).map_err(Error::wrap(|| {
|
||||
format!("Error reading query file {:?}", entry.file_name())
|
||||
}))?;
|
||||
Query::new(language, &content).map_err(Error::wrap(|| {
|
||||
format!("Error in query file {:?}", entry.file_name())
|
||||
}))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn print_diff_key() {
|
||||
println!(
|
||||
"\n{} / {}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue