test-install.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. # Test script for install.sh
  3. # This validates the install script without actually running it
  4. set -e
  5. echo "Testing install.sh script..."
  6. echo ""
  7. # Test 1: Script syntax
  8. echo "Test 1: Script Syntax Verification"
  9. if bash -n scripts/install.sh; then
  10. echo " ✅ PASS: Script syntax is valid"
  11. else
  12. echo " ❌ FAIL: Script has syntax errors"
  13. exit 1
  14. fi
  15. echo ""
  16. # Test 2: Check for required functions
  17. echo "Test 2: Required Functions Check"
  18. required_functions=(
  19. "detect_platform"
  20. "print_message"
  21. "error_exit"
  22. "command_exists"
  23. "check_prerequisites"
  24. "get_download_url"
  25. "install_cline"
  26. "configure_path"
  27. "verify_installation"
  28. "print_success"
  29. "main"
  30. )
  31. for func in "${required_functions[@]}"; do
  32. if grep -q "^$func()" scripts/install.sh || grep -q "^${func} ()" scripts/install.sh; then
  33. echo " ✅ PASS: Function '$func' exists"
  34. else
  35. echo " ❌ FAIL: Function '$func' not found"
  36. exit 1
  37. fi
  38. done
  39. echo ""
  40. # Test 3: Check for required variables
  41. echo "Test 3: Required Variables Check"
  42. required_vars=(
  43. "INSTALL_DIR"
  44. "GITHUB_REPO"
  45. "RELEASE_TAG"
  46. )
  47. for var in "${required_vars[@]}"; do
  48. if grep -q "$var=" scripts/install.sh; then
  49. echo " ✅ PASS: Variable '$var' is defined"
  50. else
  51. echo " ❌ FAIL: Variable '$var' not found"
  52. exit 1
  53. fi
  54. done
  55. echo ""
  56. # Test 4: Check for platform support
  57. echo "Test 4: Platform Support Check"
  58. platforms=("darwin-x64" "darwin-arm64" "linux-x64")
  59. for platform in "${platforms[@]}"; do
  60. if grep -q "$platform" scripts/install.sh; then
  61. echo " ✅ PASS: Platform '$platform' supported"
  62. else
  63. echo " ❌ FAIL: Platform '$platform' not found"
  64. exit 1
  65. fi
  66. done
  67. echo ""
  68. # Test 5: Check for error handling
  69. echo "Test 5: Error Handling Check"
  70. if grep -q "error_exit" scripts/install.sh && grep -q "set -e" scripts/install.sh; then
  71. echo " ✅ PASS: Error handling present"
  72. else
  73. echo " ❌ FAIL: Error handling missing"
  74. exit 1
  75. fi
  76. echo ""
  77. # Test 6: Check for PATH configuration
  78. echo "Test 6: PATH Configuration Check"
  79. if grep -q "export PATH=" scripts/install.sh; then
  80. echo " ✅ PASS: PATH configuration present"
  81. else
  82. echo " ❌ FAIL: PATH configuration missing"
  83. exit 1
  84. fi
  85. echo ""
  86. # Test 7: Check for verification step
  87. echo "Test 7: Installation Verification Check"
  88. if grep -q "verify_installation" scripts/install.sh; then
  89. echo " ✅ PASS: Installation verification present"
  90. else
  91. echo " ❌ FAIL: Installation verification missing"
  92. exit 1
  93. fi
  94. echo ""
  95. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  96. echo "All tests passed! ✅"
  97. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  98. echo ""
  99. echo "The install script is ready for use:"
  100. echo " curl -fsSL https://raw.githubusercontent.com/cline/cline/main/scripts/install.sh | bash"