test.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. # Advanced test runner with multi-agent support
  3. # Usage: ./scripts/testing/test.sh [agent] [model] [options]
  4. # Examples:
  5. # ./scripts/testing/test.sh openagent --core # Run core tests
  6. # ./scripts/testing/test.sh openagent opencode/grok-code-fast # Run all tests with specific model
  7. # ./scripts/testing/test.sh openagent --core --debug # Run core tests with debug
  8. set -e
  9. # Colors
  10. GREEN='\033[0;32m'
  11. BLUE='\033[0;34m'
  12. YELLOW='\033[1;33m'
  13. RED='\033[0;31m'
  14. NC='\033[0m' # No Color
  15. # Defaults
  16. AGENT=${1:-all}
  17. MODEL=${2:-opencode/grok-code-fast}
  18. shift 2 2>/dev/null || true
  19. EXTRA_ARGS=("$@")
  20. # Check if --core flag is present
  21. CORE_MODE=false
  22. if [[ "$AGENT" == "--core" ]] || [[ "$MODEL" == "--core" ]] || [[ "${EXTRA_ARGS[*]}" == *"--core"* ]]; then
  23. CORE_MODE=true
  24. fi
  25. echo -e "${BLUE}🧪 OpenCode Agents Test Runner${NC}"
  26. echo -e "${BLUE}================================${NC}"
  27. echo ""
  28. if [ "$CORE_MODE" = true ]; then
  29. echo -e "Mode: ${YELLOW}CORE TEST SUITE (7 tests, ~5-8 min)${NC}"
  30. fi
  31. echo -e "Agent: ${GREEN}${AGENT}${NC}"
  32. echo -e "Model: ${GREEN}${MODEL}${NC}"
  33. if [ -n "${EXTRA_ARGS[*]}" ]; then
  34. echo -e "Extra: ${YELLOW}${EXTRA_ARGS[*]}${NC}"
  35. fi
  36. # Navigate to framework directory
  37. cd "$(dirname "$0")/../../evals/framework" || exit 1
  38. # Check if dependencies are installed
  39. if [ ! -d "node_modules" ]; then
  40. echo -e "${YELLOW}⚠️ Dependencies not installed. Running npm install...${NC}"
  41. npm install
  42. echo ""
  43. fi
  44. # Run tests
  45. if [ "$AGENT" = "all" ]; then
  46. echo -e "${YELLOW}Running tests for ALL agents...${NC}"
  47. npm run eval:sdk -- --model="$MODEL" "${EXTRA_ARGS[@]}"
  48. else
  49. echo -e "${YELLOW}Running tests for ${AGENT}...${NC}"
  50. npm run eval:sdk -- --agent="$AGENT" --model="$MODEL" "${EXTRA_ARGS[@]}"
  51. fi
  52. echo -e "${BLUE}🧪 OpenCode Agents Test Runner${NC}"
  53. echo -e "${BLUE}================================${NC}"
  54. echo ""
  55. if [ "$CORE_MODE" = true ]; then
  56. echo -e "Mode: ${YELLOW}CORE TEST SUITE (7 tests, ~5-8 min)${NC}"
  57. fi
  58. echo -e "Agent: ${GREEN}${AGENT}${NC}"
  59. echo -e "Model: ${GREEN}${MODEL}${NC}"
  60. if [ -n "$EXTRA_ARGS" ]; then
  61. echo -e "Extra: ${YELLOW}${EXTRA_ARGS}${NC}"
  62. fi
  63. echo ""
  64. # Navigate to framework directory
  65. cd "$(dirname "$0")/../../evals/framework" || exit 1
  66. # Check if dependencies are installed
  67. if [ ! -d "node_modules" ]; then
  68. echo -e "${YELLOW}⚠️ Dependencies not installed. Running npm install...${NC}"
  69. npm install
  70. echo ""
  71. fi
  72. # Run tests
  73. if [ "$AGENT" = "all" ]; then
  74. echo -e "${YELLOW}Running tests for ALL agents...${NC}"
  75. npm run eval:sdk -- --model="$MODEL" $EXTRA_ARGS
  76. else
  77. echo -e "${YELLOW}Running tests for ${AGENT}...${NC}"
  78. npm run eval:sdk -- --agent="$AGENT" --model="$MODEL" $EXTRA_ARGS
  79. fi
  80. EXIT_CODE=$?
  81. echo ""
  82. if [ $EXIT_CODE -eq 0 ]; then
  83. echo -e "${GREEN}✅ Tests complete!${NC}"
  84. else
  85. echo -e "${RED}❌ Tests failed with exit code ${EXIT_CODE}${NC}"
  86. fi
  87. echo -e "${BLUE}View results: npm run dashboard${NC}"
  88. echo ""
  89. exit $EXIT_CODE