fix(test): include failing test's path in error message

This helps when an empty folder was left behind in the corpus directory
This commit is contained in:
Will Lillis 2025-09-16 03:08:01 -04:00
parent 070b91628f
commit c54bc441ba

View file

@ -1,5 +1,6 @@
use std::{collections::HashMap, env, fs};
use anyhow::Context;
use tree_sitter::Parser;
use tree_sitter_proc_macro::test_with_seed;
@ -363,7 +364,14 @@ fn test_feature_corpus_files() {
grammar_path = test_path.join("grammar.json");
}
let error_message_path = test_path.join("expected_error.txt");
let grammar_json = tree_sitter_generate::load_grammar_file(&grammar_path, None).unwrap();
let grammar_json = tree_sitter_generate::load_grammar_file(&grammar_path, None)
.with_context(|| {
format!(
"Could not load grammar file for test language '{language_name}' at {}",
grammar_path.display()
)
})
.unwrap();
let generate_result =
tree_sitter_generate::generate_parser_for_grammar(&grammar_json, Some((0, 0, 0)));