Merge pull request #2516 from ahlinc/debug-grammars-in-tests

Add `TREE_SITTER_GRAMMAR_DEBUG` env var to use debug grammars in tests
This commit is contained in:
Andrew Hlynskyi 2023-08-17 19:06:10 +03:00 committed by GitHub
commit e0e0763d29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -41,6 +41,7 @@ jobs:
- name: Run main tests with address sanitizer (ASAN)
env:
ASAN_OPTIONS: halt_on_error=1
CFLAGS: -fsanitize=address
RUSTFLAGS: -Zsanitizer=address
run: |

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 {