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
This commit is contained in:
Christian C. Berclaz 2026-05-01 22:38:52 +02:00
parent 3e637364a2
commit 74c26b0e82
No known key found for this signature in database
4 changed files with 109 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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');
});
});