#!/bin/bash # Test Execution Script for OMOP Data Pipeline # This script runs all tests with coverage reporting set -e # Exit on error # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${GREEN}OMOP Pipeline Test Suite${NC}" echo "================================" echo "" # Check if pytest is installed if ! command -v pytest &> /dev/null; then echo -e "${RED}Error: pytest not found${NC}" echo "Please install test dependencies:" echo " pip install -e .[test]" exit 1 fi # Run tests with coverage echo -e "${YELLOW}Running tests with coverage...${NC}" echo "" pytest \ --verbose \ --cov=src \ --cov-report=html \ --cov-report=term \ --cov-report=xml \ tests/ TEST_EXIT_CODE=$? echo "" if [ $TEST_EXIT_CODE -eq 0 ]; then echo -e "${GREEN}================================${NC}" echo -e "${GREEN}All tests passed!${NC}" echo -e "${GREEN}================================${NC}" echo "" echo "Coverage report generated:" echo " HTML: htmlcov/index.html" echo " XML: coverage.xml" echo "" else echo -e "${RED}================================${NC}" echo -e "${RED}Some tests failed${NC}" echo -e "${RED}================================${NC}" echo "" exit $TEST_EXIT_CODE fi # Optional: Run linting if command -v flake8 &> /dev/null; then echo -e "${YELLOW}Running code quality checks...${NC}" flake8 src/ --max-line-length=100 --exclude=__pycache__,*.pyc echo -e "${GREEN}✓ Code quality checks passed${NC}" echo "" fi # Optional: Run type checking if command -v mypy &> /dev/null; then echo -e "${YELLOW}Running type checks...${NC}" mypy src/ --ignore-missing-imports echo -e "${GREEN}✓ Type checks passed${NC}" echo "" fi echo -e "${GREEN}Test suite completed successfully!${NC}"