#!/bin/bash # WAVE 102: Automated Coverage Testing Script # Switches to coverage-compatible config, runs coverage, then restores production config set -e echo "๐Ÿ”ง WAVE 102: Coverage Tool Runner" echo "=================================" echo "" # Backup current config echo "๐Ÿ“ฆ Backing up current config..." cp .cargo/config.toml .cargo/config.toml.backup # Switch to coverage config echo "๐Ÿ”„ Switching to coverage-compatible config..." cp .cargo/config.toml.coverage .cargo/config.toml # Clean build artifacts echo "๐Ÿงน Cleaning build artifacts..." cargo clean # Run coverage echo "๐Ÿ“Š Running coverage analysis..." if [ "$1" == "--workspace" ]; then echo " Target: Entire workspace" cargo llvm-cov --workspace --html --output-dir target/coverage --ignore-run-fail elif [ -n "$1" ]; then echo " Target: Package '$1'" cargo llvm-cov --package "$1" --html --output-dir target/coverage --ignore-run-fail else echo " Target: common (default)" cargo llvm-cov --package common --html --output-dir target/coverage --ignore-run-fail fi # Generate JSON for parsing echo "๐Ÿ“ Generating JSON coverage data..." if [ "$1" == "--workspace" ]; then cargo llvm-cov --workspace --json --output-path target/coverage/coverage.json --ignore-run-fail 2>/dev/null || echo " (some tests failed, but coverage generated)" elif [ -n "$1" ]; then cargo llvm-cov --package "$1" --json --output-path target/coverage/"$1".json --ignore-run-fail 2>/dev/null || echo " (some tests failed, but coverage generated)" else cargo llvm-cov --package common --json --output-path target/coverage/common.json --ignore-run-fail 2>/dev/null || echo " (some tests failed, but coverage generated)" fi # Restore original config echo "โ™ป๏ธ Restoring production config..." cp .cargo/config.toml.backup .cargo/config.toml rm .cargo/config.toml.backup echo "" echo "โœ… Coverage analysis complete!" echo " HTML report: target/coverage/html/index.html" echo " JSON data: target/coverage/*.json" echo "" echo "To view HTML report:" echo " xdg-open target/coverage/html/index.html" echo ""