From 74c26b0e8244e9bf15b698f2539e8d44b8a5e507 Mon Sep 17 00:00:00 2001 From: "Christian C. Berclaz" Date: Fri, 1 May 2026 22:38:52 +0200 Subject: [PATCH] test(lua): add integration test with multi-file fixture 3-file Lua fixture (user.lua, service.lua, main.lua) exercising: - File detection across nested directories - Function and method extraction (local, global, dot, colon syntax) - require() import edge creation - Cross-file call resolution --- .../lang-resolution/lua-app/lib/service.lua | 22 +++++++ .../lang-resolution/lua-app/lib/user.lua | 19 ++++++ .../fixtures/lang-resolution/lua-app/main.lua | 9 +++ .../test/integration/resolvers/lua.test.ts | 59 +++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 gitnexus/test/fixtures/lang-resolution/lua-app/lib/service.lua create mode 100644 gitnexus/test/fixtures/lang-resolution/lua-app/lib/user.lua create mode 100644 gitnexus/test/fixtures/lang-resolution/lua-app/main.lua create mode 100644 gitnexus/test/integration/resolvers/lua.test.ts diff --git a/gitnexus/test/fixtures/lang-resolution/lua-app/lib/service.lua b/gitnexus/test/fixtures/lang-resolution/lua-app/lib/service.lua new file mode 100644 index 000000000..9e8453262 --- /dev/null +++ b/gitnexus/test/fixtures/lang-resolution/lua-app/lib/service.lua @@ -0,0 +1,22 @@ +local User = require("lib.user") + +local Service = {} +Service.__index = Service + +function Service.new() + local self = setmetatable({}, Service) + return self +end + +function Service:create_user(name, email) + local user = User.new(name, email) + return user +end + +function Service:process(user) + local greeting = user:greet() + print(greeting) + return greeting +end + +return Service diff --git a/gitnexus/test/fixtures/lang-resolution/lua-app/lib/user.lua b/gitnexus/test/fixtures/lang-resolution/lua-app/lib/user.lua new file mode 100644 index 000000000..fdffdebf8 --- /dev/null +++ b/gitnexus/test/fixtures/lang-resolution/lua-app/lib/user.lua @@ -0,0 +1,19 @@ +local User = {} +User.__index = User + +function User.new(name, email) + local self = setmetatable({}, User) + self.name = name + self.email = email + return self +end + +function User:greet() + return "Hello, " .. self.name +end + +function User:get_email() + return self.email +end + +return User diff --git a/gitnexus/test/fixtures/lang-resolution/lua-app/main.lua b/gitnexus/test/fixtures/lang-resolution/lua-app/main.lua new file mode 100644 index 000000000..8d500cd14 --- /dev/null +++ b/gitnexus/test/fixtures/lang-resolution/lua-app/main.lua @@ -0,0 +1,9 @@ +local Service = require("lib.service") + +local function main() + local svc = Service.new() + local user = svc:create_user("Alice", "alice@example.com") + svc:process(user) +end + +main() diff --git a/gitnexus/test/integration/resolvers/lua.test.ts b/gitnexus/test/integration/resolvers/lua.test.ts new file mode 100644 index 000000000..6da9eb433 --- /dev/null +++ b/gitnexus/test/integration/resolvers/lua.test.ts @@ -0,0 +1,59 @@ +/** + * Lua: basic pipeline integration — functions, methods, imports, calls. + * Verifies that the Lua language provider correctly parses module-pattern + * classes, colon-syntax methods, require() imports, and cross-file calls. + */ +import { describe, it, expect, beforeAll } from 'vitest'; +import path from 'path'; +import { + FIXTURES, + getRelationships, + getNodesByLabel, + edgeSet, + runPipelineFromRepo, + type PipelineResult, +} from './helpers.js'; +import { isLanguageAvailable } from '../../../src/core/tree-sitter/parser-loader.js'; +import { SupportedLanguages } from '../../../src/config/supported-languages.js'; + +const luaAvailable = isLanguageAvailable(SupportedLanguages.Lua); + +describe.skipIf(!luaAvailable)('Lua pipeline integration', () => { + let result: PipelineResult; + + beforeAll(async () => { + result = await runPipelineFromRepo(path.join(FIXTURES, 'lua-app'), () => {}); + }, 60000); + + it('detects Lua files', () => { + const files = getNodesByLabel(result, 'File'); + expect(files).toContain('main.lua'); + expect(files).toContain('user.lua'); + expect(files).toContain('service.lua'); + }); + + it('extracts functions and methods', () => { + const functions = getNodesByLabel(result, 'Function'); + const methods = getNodesByLabel(result, 'Method'); + const allSymbols = [...functions, ...methods]; + expect(allSymbols).toContain('main'); + expect(allSymbols).toContain('new'); + expect(allSymbols).toContain('greet'); + expect(allSymbols).toContain('get_email'); + expect(allSymbols).toContain('create_user'); + expect(allSymbols).toContain('process'); + }); + + it('extracts require() import edges', () => { + const imports = getRelationships(result, 'IMPORTS'); + const importEdges = edgeSet(imports); + expect(importEdges.length).toBeGreaterThanOrEqual(1); + }); + + it('extracts call edges', () => { + const calls = getRelationships(result, 'CALLS'); + expect(calls.length).toBeGreaterThanOrEqual(1); + const callNames = calls.map((c) => c.target); + expect(callNames).toContain('main'); + }); +});