From 72f982cc9d12036fba253d3469dc247ce870aa30 Mon Sep 17 00:00:00 2001 From: taoxin <> Date: Mon, 3 Aug 2026 11:36:31 +0800 Subject: [PATCH] test(lua): complete grammar coverage, ABI smoke, and docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to 4c8937b (feat: add Lua language support) — wire Lua into the test and doc surface the feature commit omitted. - grammar-update-monitor: GRAMMARS registry now asserts six grammars (swift/kotlin/lua/c npm, dart/proto github) and that lua.hold is set; the vendored nan-based binding is incompatible with the pinned tree-sitter@0.21.1 runtime and must not auto-bump. - language-skip: Lua is available in the default install (vendored grammar), unlike the optional Kotlin dependency. - parser-loader-abi: add a Lua smoke case (root type `chunk`). - parsing: drop the stale assertion that getLanguageFromFilename returns null for `module.lua` — Lua is now registered in language-detection, so it resolves to "lua". - README: add the Lua row to the supported-languages table. Verified: tsc --noEmit clean; grammar-update-monitor, language-skip, parser-loader-abi unit suites and parsing.test.ts integration suite pass. Co-Authored-By: Claude Sonnet 4 --- README.md | 1 + gitnexus/test/integration/parsing.test.ts | 3 --- .../test/unit/grammar-update-monitor.test.ts | 18 +++++++++++++++--- gitnexus/test/unit/language-skip.test.ts | 4 ++++ gitnexus/test/unit/parser-loader-abi.test.ts | 5 +++++ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e26373aff..7747924ea 100644 --- a/README.md +++ b/README.md @@ -580,6 +580,7 @@ GitNexus builds a complete knowledge graph of your codebase through a multi-phas | C | — | — | ✓ | — | ✓ | ✓ | — | ✓ | ✓ | | C++ | — | — | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ | | Dart | ✓ | — | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ | +| Lua | ✓ | — | ✓ | ✓ | — | ✓ | — | ✓ | ✓ | **Imports** — cross-file import resolution · **Named Bindings** — `import { X as Y }` / re-export tracking · **Exports** — public/exported symbol detection · **Heritage** — class inheritance, interfaces, mixins · **Type Annotations** — explicit type extraction for receiver resolution · **Constructor Inference** — infer receiver type from constructor calls (`self`/`this` resolution included for all languages) · **Config** — language toolchain config parsing (tsconfig, go.mod, etc.) · **Frameworks** — AST-based framework pattern detection · **Entry Points** — entry point scoring heuristics diff --git a/gitnexus/test/integration/parsing.test.ts b/gitnexus/test/integration/parsing.test.ts index 9f9079c18..7798adb0f 100644 --- a/gitnexus/test/integration/parsing.test.ts +++ b/gitnexus/test/integration/parsing.test.ts @@ -935,9 +935,6 @@ describe('parsing', () => { const scalaLang = getLanguageFromFilename('Main.scala'); expect(scalaLang).toBeNull(); - const luaLang = getLanguageFromFilename('module.lua'); - expect(luaLang).toBeNull(); - // loadLanguage throws an explicit error for a language not in the grammar map. // Cast through unknown to simulate a caller passing an unrecognised language key. await expect(loadLanguage('erlang' as unknown as SupportedLanguages)).rejects.toThrow( diff --git a/gitnexus/test/unit/grammar-update-monitor.test.ts b/gitnexus/test/unit/grammar-update-monitor.test.ts index e04dc3989..af05cbb14 100644 --- a/gitnexus/test/unit/grammar-update-monitor.test.ts +++ b/gitnexus/test/unit/grammar-update-monitor.test.ts @@ -73,19 +73,31 @@ describe('COMPATIBLE_ABI gate', () => { }); describe('GRAMMARS registry', () => { - it('covers all five grammars (swift/kotlin npm, dart/proto github, c npm)', () => { - expect(Object.keys(mod.GRAMMARS).sort()).toEqual(['c', 'dart', 'kotlin', 'proto', 'swift']); + it('covers all six grammars (swift/kotlin/lua/c npm, dart/proto github)', () => { + expect(Object.keys(mod.GRAMMARS).sort()).toEqual([ + 'c', + 'dart', + 'kotlin', + 'lua', + 'proto', + 'swift', + ]); expect(mod.GRAMMARS.swift.npm).toBe('tree-sitter-swift'); expect(mod.GRAMMARS.dart.github).toContain('tree-sitter-dart'); + expect(mod.GRAMMARS.lua.npm).toBe('tree-sitter-lua'); }); - it('marks c and kotlin report-only (holds); swift/dart/proto are auto-updatable', () => { + it('marks c, kotlin, lua report-only (holds); swift/dart/proto are auto-updatable', () => { expect(mod.GRAMMARS.c.npm).toBe('tree-sitter-c'); expect(mod.GRAMMARS.c.hold).toBeTruthy(); // ABI-pinned: detected/reported, never auto-applied // kotlin is pinned to an unreleased fwcd main commit for `fun interface` // support (#169); npm latest (0.3.8) lacks it, so the strict-inequality // isNewer would auto-revert the pin without this hold. expect(mod.GRAMMARS.kotlin.hold).toBeTruthy(); + // lua ships nan-based bindings incompatible with the pinned tree-sitter + // runtime; vendored with a rebuilt Napi binding, so the monitor must not + // auto-bump until the runtime upgrades and upstream migrates to Napi. + expect(mod.GRAMMARS.lua.hold).toBeTruthy(); for (const k of ['swift', 'dart', 'proto']) { expect(mod.GRAMMARS[k].hold).toBeUndefined(); } diff --git a/gitnexus/test/unit/language-skip.test.ts b/gitnexus/test/unit/language-skip.test.ts index 19c90cf3e..4f7de7887 100644 --- a/gitnexus/test/unit/language-skip.test.ts +++ b/gitnexus/test/unit/language-skip.test.ts @@ -23,6 +23,10 @@ describe('isLanguageAvailable', () => { expect(isLanguageAvailable(SupportedLanguages.Swift)).toBe(true); }); + it('returns true for Lua in the default install (vendored grammar)', () => { + expect(isLanguageAvailable(SupportedLanguages.Lua)).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); diff --git a/gitnexus/test/unit/parser-loader-abi.test.ts b/gitnexus/test/unit/parser-loader-abi.test.ts index 7b467ba55..64bd97e99 100644 --- a/gitnexus/test/unit/parser-loader-abi.test.ts +++ b/gitnexus/test/unit/parser-loader-abi.test.ts @@ -112,6 +112,11 @@ const SMOKE_CASES: Record = { snippet: 'void main() {}\n', rootType: 'program', }, + [SupportedLanguages.Lua]: { + language: SupportedLanguages.Lua, + snippet: 'local x = 1\n', + rootType: 'chunk', + }, [SupportedLanguages.Kotlin]: { language: SupportedLanguages.Kotlin, snippet: 'fun main() {}\n',