#!/bin/bash

# Simple Test Coverage Script for Wasot Compiler
# Quick coverage analysis with terminal output

set -e

echo "🧪 Running Test Coverage Analysis..."

# Check if we're in the right directory
if [ ! -f "Cargo.toml" ]; then
    echo "❌ Error: Run from project root directory"
    exit 1
fi

# Install cargo-tarpaulin if not available
if ! command -v cargo-tarpaulin &> /dev/null; then
    echo "📦 Installing cargo-tarpaulin..."
    cargo install cargo-tarpaulin
fi

# Run coverage analysis with terminal output
cargo tarpaulin \
    --all-features \
    --workspace \
    --timeout 120 \
    --exclude-files "target/*" \
    --exclude-files "*/tests.rs" \
    --exclude-files "*/main.rs" \
    --line \
    --branch

echo ""
echo "✅ Coverage analysis complete!"
echo "💡 For detailed HTML report, run: ./scripts/ci/test_coverage.sh"