test(bash): add integration test with multi-file fixture

3-file Bash fixture (utils.sh, service.sh, main.sh) exercising:
file detection, function extraction, source import edges, and
cross-file call resolution.
This commit is contained in:
Christian C. Berclaz 2026-05-01 23:15:59 +02:00
parent c350181c27
commit 7e679f3d89
No known key found for this signature in database
4 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,19 @@
#!/bin/bash
source lib/utils.sh
SERVICE_NAME="myapp"
create_user() {
local name="$1"
local email="$2"
log_message "info" "Creating user: $name"
echo "$name:$email"
}
process_user() {
local user="$1"
local formatted
formatted=$(format_name "$user")
log_message "info" "Processed: $formatted"
}

View file

@ -0,0 +1,14 @@
#!/bin/bash
LOG_LEVEL="info"
log_message() {
local level="$1"
local msg="$2"
echo "[$level] $msg"
}
format_name() {
local name="$1"
echo "${name^^}"
}

View file

@ -0,0 +1,11 @@
#!/bin/bash
source lib/service.sh
main() {
local user
user=$(create_user "Alice" "alice@example.com")
process_user "$user"
}
main "$@"

View file

@ -0,0 +1,52 @@
/**
* Bash: basic pipeline integration — functions, source imports, calls, variables.
*/
import { describe, it, expect, beforeAll } from 'vitest';
import path from 'path';
import {
FIXTURES,
getRelationships,
getNodesByLabel,
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 bashAvailable = isLanguageAvailable(SupportedLanguages.Bash);
describe.skipIf(!bashAvailable)('Bash pipeline integration', () => {
let result: PipelineResult;
beforeAll(async () => {
result = await runPipelineFromRepo(path.join(FIXTURES, 'bash-app'), () => {});
}, 60000);
it('detects Bash files', () => {
const files = getNodesByLabel(result, 'File');
expect(files).toContain('main.sh');
expect(files).toContain('utils.sh');
expect(files).toContain('service.sh');
});
it('extracts functions', () => {
const functions = getNodesByLabel(result, 'Function');
expect(functions).toContain('main');
expect(functions).toContain('log_message');
expect(functions).toContain('format_name');
expect(functions).toContain('create_user');
expect(functions).toContain('process_user');
});
it('extracts call edges', () => {
const calls = getRelationships(result, 'CALLS');
expect(calls.length).toBeGreaterThanOrEqual(1);
const callNames = calls.map((c) => c.target);
expect(callNames).toContain('create_user');
});
it('extracts source import edges', () => {
const imports = getRelationships(result, 'IMPORTS');
expect(imports.length).toBeGreaterThanOrEqual(1);
});
});