mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-28 01:31:23 +00:00
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:
parent
c350181c27
commit
7e679f3d89
4 changed files with 96 additions and 0 deletions
19
gitnexus/test/fixtures/lang-resolution/bash-app/lib/service.sh
vendored
Normal file
19
gitnexus/test/fixtures/lang-resolution/bash-app/lib/service.sh
vendored
Normal 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"
|
||||
}
|
||||
14
gitnexus/test/fixtures/lang-resolution/bash-app/lib/utils.sh
vendored
Normal file
14
gitnexus/test/fixtures/lang-resolution/bash-app/lib/utils.sh
vendored
Normal 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^^}"
|
||||
}
|
||||
11
gitnexus/test/fixtures/lang-resolution/bash-app/main.sh
vendored
Normal file
11
gitnexus/test/fixtures/lang-resolution/bash-app/main.sh
vendored
Normal 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 "$@"
|
||||
52
gitnexus/test/integration/resolvers/bash.test.ts
Normal file
52
gitnexus/test/integration/resolvers/bash.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue