test_integration.sh
1 #!/bin/bash 2 # Manual integration test for bar_complete 3 4 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 5 REPO_ROOT="$(dirname "$SCRIPT_DIR")" 6 7 cd "$SCRIPT_DIR" || exit 1 8 9 # shellcheck disable=SC1091 10 source "$REPO_ROOT/contrib/bar_complete" 11 12 test_integration() { 13 echo "Testing bar_complete integration..." 14 echo "====================================" 15 echo 16 17 # Test 1: Initialize and update cache 18 echo "Test 1: Initializing cache..." 19 __bar_init_completion_registry 20 __bar_update_cache "bar" 21 echo "✓ Cache initialized" 22 echo 23 24 # Test 2: Check if test_barf functions are discovered 25 echo "Test 2: Checking discovered functions..." 26 if [[ -v __bar_func_params[test_completion_func] ]]; then 27 echo "✓ test_completion_func discovered" 28 echo " Parameters: ${__bar_func_params[test_completion_func]}" 29 else 30 echo "✗ test_completion_func not discovered" 31 fi 32 echo 33 34 # Test 3: Check if rules are discovered 35 echo "Test 3: Checking discovered rules..." 36 if [[ -v __bar_rule_params[test_build] ]]; then 37 echo "✓ test_build rule discovered" 38 echo " Parameters: ${__bar_rule_params[test_build]}" 39 else 40 echo "✗ test_build rule not discovered" 41 fi 42 echo 43 44 # Test 4: Test parameter completion 45 echo "Test 4: Testing parameter completion..." 46 local result 47 result=$(__bar_params "test_completion_func" "test" 2>/dev/null | head -5) 48 echo "Completions for 'test_completion_func test*':" 49 if [[ -n "$result" ]]; then 50 while IFS= read -r line; do 51 echo " $line" 52 done <<< "$result" 53 else 54 echo " (file completions)" 55 fi 56 echo 57 58 # Test 5: Test rule completion 59 echo "Test 5: Testing rule name completion..." 60 result=$(__bar_rule "test" 2>/dev/null) 61 echo "Rules starting with 'test':" 62 if [[ -n "$result" ]]; then 63 while IFS= read -r line; do 64 echo " $line" 65 done <<< "$result" 66 else 67 echo " (none found)" 68 fi 69 echo 70 71 # Test 6: Check cargo module completer detection 72 echo "Test 6: Checking module-specific completers..." 73 if [[ -v __bar_protoregistry["cargo@toolchain"] ]]; then 74 echo "✓ cargo@toolchain completer registered" 75 echo " Completer: ${__bar_protoregistry[cargo@toolchain]}" 76 else 77 echo "ℹ cargo@toolchain completer not found (cargo module not loaded)" 78 fi 79 echo 80 81 echo "====================================" 82 echo "Integration test complete" 83 } 84 85 test_integration 86