test(ingestion): probe the Dart parser before enabling its providers suite (#3354)

isLanguageAvailable only proves the module loaded; tree-sitter-dart can still
fail on setLanguage. Probe loadParser/loadLanguage and skip on failure, the
same guard dart.test.ts uses.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gergo Magyar 2026-09-25 19:05:26 +00:00
parent 24104749ea
commit 09933f3a38

View file

@ -19,14 +19,28 @@ import {
runPipelineFromRepo,
type PipelineResult,
} from './helpers.js';
import { isLanguageAvailable } from '../../../src/core/tree-sitter/parser-loader.js';
import {
isLanguageAvailable,
loadParser,
loadLanguage,
} from '../../../src/core/tree-sitter/parser-loader.js';
import { SupportedLanguages } from '../../../src/config/supported-languages.js';
// Kotlin, Swift and Dart grammars are optional installs; skip their suites
// when the grammar did not load, as the per-language resolver suites do.
const kotlinAvailable = isLanguageAvailable(SupportedLanguages.Kotlin);
const swiftAvailable = isLanguageAvailable(SupportedLanguages.Swift);
const dartAvailable = isLanguageAvailable(SupportedLanguages.Dart);
// A loaded tree-sitter-dart module can still fail on setLanguage, so probe the
// parser too (same guard as dart.test.ts).
let dartAvailable = isLanguageAvailable(SupportedLanguages.Dart);
if (dartAvailable) {
try {
await loadParser();
await loadLanguage(SupportedLanguages.Dart);
} catch {
dartAvailable = false;
}
}
const runFixture = (name: string): Promise<PipelineResult> =>
runPipelineFromRepo(path.join(FIXTURES, name), () => {});