test.sh 886 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  4. cd "$SCRIPT_DIR"
  5. # Prefer the project-local venv so tests are independent of caller shell state.
  6. if [[ -f ".venv/bin/activate" ]]; then
  7. # shellcheck disable=SC1091
  8. source .venv/bin/activate
  9. fi
  10. if [[ -n "${GARDEN_LAYER_VENV:-}" ]]; then
  11. if [[ -f "$GARDEN_LAYER_VENV/bin/activate" ]]; then
  12. # shellcheck disable=SC1091
  13. source "$GARDEN_LAYER_VENV/bin/activate"
  14. else
  15. echo "Warning: GARDEN_LAYER_VENV is set to '$GARDEN_LAYER_VENV' but the activate script is missing." >&2
  16. fi
  17. fi
  18. export PYTHONPATH="$PWD/src${PYTHONPATH:+:$PYTHONPATH}"
  19. export MCP_ALLOW_EXAMPLE_LOAD="${MCP_ALLOW_EXAMPLE_LOAD:-true}"
  20. if ! python3 -c "import requests, pytest" >/dev/null 2>&1; then
  21. python3 -m pip install -r requirements.txt >/dev/null
  22. fi
  23. python3 -m pytest -v -s test_garden_layer.py