diff --git a/gitnexus/test/fixtures/lang-resolution/bash-app/lib/service.sh b/gitnexus/test/fixtures/lang-resolution/bash-app/lib/service.sh new file mode 100644 index 000000000..2951b18a2 --- /dev/null +++ b/gitnexus/test/fixtures/lang-resolution/bash-app/lib/service.sh @@ -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" +} diff --git a/gitnexus/test/fixtures/lang-resolution/bash-app/lib/utils.sh b/gitnexus/test/fixtures/lang-resolution/bash-app/lib/utils.sh new file mode 100644 index 000000000..0e2c5195f --- /dev/null +++ b/gitnexus/test/fixtures/lang-resolution/bash-app/lib/utils.sh @@ -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^^}" +} diff --git a/gitnexus/test/fixtures/lang-resolution/bash-app/main.sh b/gitnexus/test/fixtures/lang-resolution/bash-app/main.sh new file mode 100644 index 000000000..08d664986 --- /dev/null +++ b/gitnexus/test/fixtures/lang-resolution/bash-app/main.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +source lib/service.sh + +main() { + local user + user=$(create_user "Alice" "alice@example.com") + process_user "$user" +} + +main "$@" diff --git a/gitnexus/test/integration/resolvers/bash.test.ts b/gitnexus/test/integration/resolvers/bash.test.ts new file mode 100644 index 000000000..f8e5b6987 --- /dev/null +++ b/gitnexus/test/integration/resolvers/bash.test.ts @@ -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); + }); +});