Add TREE_SITTER_GRAMMAR_DEBUG env var to use debug grammars in tests

This commit is contained in:
Andrew Hlynskyi 2023-08-17 18:16:41 +03:00
parent 5fbb2775aa
commit 0dd85c8452
2 changed files with 12 additions and 2 deletions

View file

@ -105,6 +105,10 @@ fn test_language_corpus(start_seed: usize, language_name: &str) {
let log_seed = env::var("TREE_SITTER_LOG_SEED").is_ok();
if log_seed {
println!(" start seed: {}", start_seed);
}
println!();
for test in tests {
println!(" {} example - {}", language_name, test.name);

View file

@ -1,6 +1,6 @@
use lazy_static::lazy_static;
use std::fs;
use std::path::{Path, PathBuf};
use std::{env, fs};
use tree_sitter::Language;
use tree_sitter_highlight::HighlightConfiguration;
use tree_sitter_loader::Loader;
@ -9,7 +9,13 @@ use tree_sitter_tags::TagsConfiguration;
include!("./dirs.rs");
lazy_static! {
static ref TEST_LOADER: Loader = Loader::with_parser_lib_path(SCRATCH_DIR.clone());
static ref TEST_LOADER: Loader = {
let mut loader = Loader::with_parser_lib_path(SCRATCH_DIR.clone());
if env::var("TREE_SITTER_GRAMMAR_DEBUG").is_ok() {
loader.use_debug_build(true);
}
loader
};
}
pub fn test_loader<'a>() -> &'a Loader {