GitNexus/gitnexus/test/unit/language-skip.test.ts
Gergő Magyar 1f6df5fdbb
fix(swift): use official prebuilt parser runtime (#1130)
* fix(swift): use official prebuilt parser runtime

Vendor the official tree-sitter-swift 0.7.1 runtime package so Swift parsing works without source-building, while keeping the repo on the current tree-sitter runtime until the broader upgrade is ready. Also preserves Swift resolver correctness for overloaded owned functions and extension-backed type duplicates now that Swift is available by default.

Made-with: Cursor

* fix(swift): move duplicate type ordering into provider

Keep Swift extension candidate ordering behind the LanguageProvider contract and cover the Swift 0.7 init scanner path so parser runtime changes do not leak language-specific logic into shared resolution.

Made-with: Cursor

* fix(swift): address parser runtime review

Add explicit Swift prebuild checks and vendor guidance so parser runtime packaging remains observable and maintainable.
2026-04-28 09:57:42 +01:00

45 lines
2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { isLanguageAvailable, loadLanguage } from '../../src/core/tree-sitter/parser-loader.js';
import { SupportedLanguages } from '../../src/config/supported-languages.js';
describe('isLanguageAvailable', () => {
it('returns true for installed languages', () => {
expect(isLanguageAvailable(SupportedLanguages.TypeScript)).toBe(true);
expect(isLanguageAvailable(SupportedLanguages.JavaScript)).toBe(true);
expect(isLanguageAvailable(SupportedLanguages.Python)).toBe(true);
expect(isLanguageAvailable(SupportedLanguages.Java)).toBe(true);
expect(isLanguageAvailable(SupportedLanguages.Go)).toBe(true);
expect(isLanguageAvailable(SupportedLanguages.Rust)).toBe(true);
expect(isLanguageAvailable(SupportedLanguages.PHP)).toBe(true);
expect(isLanguageAvailable(SupportedLanguages.Ruby)).toBe(true);
});
it('returns false for fabricated language values', () => {
expect(isLanguageAvailable('erlang' as SupportedLanguages)).toBe(false);
expect(isLanguageAvailable('haskell' as SupportedLanguages)).toBe(false);
});
it('returns true for Swift in the default install', () => {
expect(isLanguageAvailable(SupportedLanguages.Swift)).toBe(true);
});
it('handles Kotlin based on optional dependency availability', () => {
// Kotlin is now optional — result depends on whether tree-sitter-kotlin is installed
const result = isLanguageAvailable(SupportedLanguages.Kotlin);
expect(typeof result).toBe('boolean');
// Either way, it should not throw
});
});
describe('Kotlin optional dependency', () => {
it('handles Kotlin loading gracefully', async () => {
// Kotlin is optional — it either loads successfully or throws an error
try {
await loadLanguage(SupportedLanguages.Kotlin);
// If it succeeds, tree-sitter-kotlin is installed
} catch (e: any) {
// If it fails, it should be because tree-sitter-kotlin is not installed
expect(e.message).toContain('Unsupported language');
}
});
});