test.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 and argument parsing
  16. AGENT=all
  17. MODEL=opencode/grok-code-fast
  18. AGENT_SET=false
  19. MODEL_SET=false
  20. CORE_MODE=false
  21. EXTRA_ARGS=()
  22. while [ $# -gt 0 ]; do
  23. case "$1" in
  24. --core)
  25. CORE_MODE=true
  26. ;;
  27. --*)
  28. EXTRA_ARGS+=("$1")
  29. ;;
  30. *)
  31. if [ "$AGENT_SET" = false ]; then
  32. AGENT="$1"
  33. AGENT_SET=true
  34. elif [ "$MODEL_SET" = false ]; then
  35. MODEL="$1"
  36. MODEL_SET=true
  37. else
  38. EXTRA_ARGS+=("$1")
  39. fi
  40. ;;
  41. esac
  42. shift
  43. done
  44. echo -e "${BLUE}🧪 OpenCode Agents Test Runner${NC}"
  45. echo -e "${BLUE}================================${NC}"
  46. echo ""
  47. if [ "$CORE_MODE" = true ]; then
  48. echo -e "Mode: ${YELLOW}CORE TEST SUITE (7 tests, ~5-8 min)${NC}"
  49. fi
  50. echo -e "Agent: ${GREEN}${AGENT}${NC}"
  51. echo -e "Model: ${GREEN}${MODEL}${NC}"
  52. if [ -n "${EXTRA_ARGS[*]}" ]; then
  53. echo -e "Extra: ${YELLOW}${EXTRA_ARGS[*]}${NC}"
  54. fi
  55. REPO_ROOT=$(cd "$(dirname "$0")/../.." && pwd)
  56. # Check if dependencies are installed
  57. if [ ! -d "$REPO_ROOT/node_modules" ]; then
  58. echo -e "${YELLOW}⚠️ Dependencies not installed. Running pnpm install...${NC}"
  59. pnpm --dir "$REPO_ROOT" install
  60. echo ""
  61. fi
  62. # Run tests
  63. EVAL_SCRIPT=eval:sdk
  64. if [ "$CORE_MODE" = true ]; then
  65. EVAL_SCRIPT=eval:sdk:core
  66. fi
  67. if [ "$AGENT" = "all" ]; then
  68. echo -e "${YELLOW}Running tests for ALL agents...${NC}"
  69. pnpm --dir "$REPO_ROOT/evals/framework" run "$EVAL_SCRIPT" -- --model="$MODEL" "${EXTRA_ARGS[@]}" && EXIT_CODE=0 || EXIT_CODE=$?
  70. else
  71. echo -e "${YELLOW}Running tests for ${AGENT}...${NC}"
  72. pnpm --dir "$REPO_ROOT/evals/framework" run "$EVAL_SCRIPT" -- --agent="$AGENT" --model="$MODEL" "${EXTRA_ARGS[@]}" && EXIT_CODE=0 || EXIT_CODE=$?
  73. fi
  74. echo ""
  75. if [ $EXIT_CODE -eq 0 ]; then
  76. echo -e "${GREEN}✅ Tests complete!${NC}"
  77. else
  78. echo -e "${RED}❌ Tests failed with exit code ${EXIT_CODE}${NC}"
  79. fi
  80. echo -e "${BLUE}View results: pnpm run dashboard${NC}"
  81. echo ""
  82. exit $EXIT_CODE