Skip to content

Commit 84ea30f

Browse files
unhappychoiceclaude
andcommitted
test(syntax): assert every highlight and injection query compiles
Query errors are swallowed with .ok() at runtime, so broken queries went unnoticed in CI. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c202bce commit 84ea30f

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/syntax/languages/mod.rs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ impl LanguageKind {
359359
#[cfg(test)]
360360
mod tests {
361361
use super::*;
362-
use tree_sitter::Parser;
362+
use tree_sitter::{Parser, Query};
363363

364364
const SUPPORTED_LANGUAGES: [(&str, bool); 34] = [
365365
("astro", true),
@@ -453,6 +453,19 @@ mod tests {
453453
});
454454
}
455455

456+
#[test]
457+
fn every_supported_language_query_compiles() {
458+
SUPPORTED_LANGUAGES.iter().for_each(|(name, _)| {
459+
let support = get_language_by_name(name).expect("language should resolve");
460+
let highlight = Query::new(&support.language, support.highlight_query);
461+
assert!(highlight.is_ok(), "{name}: {:?}", highlight.err());
462+
support.injection_query.iter().for_each(|source| {
463+
let injection = Query::new(&support.language, source);
464+
assert!(injection.is_ok(), "{name}: {:?}", injection.err());
465+
});
466+
});
467+
}
468+
456469
#[test]
457470
fn aliases_resolve_to_the_same_language_support() {
458471
CANONICAL_ALIASES.iter().for_each(|(alias, canonical)| {

0 commit comments

Comments
 (0)