From 0dd85c84521fe8b10d26275b70578a28753c55be Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Thu, 17 Aug 2023 18:16:41 +0300 Subject: [PATCH 1/2] Add TREE_SITTER_GRAMMAR_DEBUG env var to use debug grammars in tests --- cli/src/tests/corpus_test.rs | 4 ++++ cli/src/tests/helpers/fixtures.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cli/src/tests/corpus_test.rs b/cli/src/tests/corpus_test.rs index a193c029..f7b4815b 100644 --- a/cli/src/tests/corpus_test.rs +++ b/cli/src/tests/corpus_test.rs @@ -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); diff --git a/cli/src/tests/helpers/fixtures.rs b/cli/src/tests/helpers/fixtures.rs index 46c674cd..f790ed75 100644 --- a/cli/src/tests/helpers/fixtures.rs +++ b/cli/src/tests/helpers/fixtures.rs @@ -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 { From e9bed05c7c554630e06e8aaaef1fee081e78ed0b Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Thu, 17 Aug 2023 18:26:08 +0300 Subject: [PATCH 2/2] chore(ci): explicitly define halt on error for ASAN detected issues --- .github/workflows/sanitize.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sanitize.yml b/.github/workflows/sanitize.yml index bb085eae..834c5ab4 100644 --- a/.github/workflows/sanitize.yml +++ b/.github/workflows/sanitize.yml @@ -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: |