#!/bin/bash # Test runner script for nigig-map # # Usage: # ./tools/run_map_tests.sh [test_type] # # Test types: # all - Run all tests (default) # unit - Run unit tests only # integration - Run integration tests only # bench - Run benchmarks # fuzz - Run fuzz tests (requires cargo-fuzz) # coverage - Run tests with coverage (requires cargo-tarpaulin) set -e TEST_TYPE="${1:-all}" echo "==========================================" echo "Nigig Map Test Runner" echo "==========================================" echo "" cd "$(dirname "$0")/../crates/apps/map" case "$TEST_TYPE" in all) echo "Running all tests..." echo "" echo "--- Unit Tests ---" cargo test --lib echo "" echo "--- Integration Tests ---" cargo test --test tile_decode_integration cargo test --test render_graph_tests echo "" echo "--- Clippy Lints ---" cargo clippy -- -D warnings echo "" echo "--- Format Check ---" cargo fmt -- --check echo "" echo "All tests passed! ✅" ;; unit) echo "Running unit tests..." cargo test --lib echo "Unit tests passed! ✅" ;; integration) echo "Running integration tests..." cargo test --test tile_decode_integration cargo test --test render_graph_tests echo "Integration tests passed! ✅" ;; bench) echo "Running benchmarks..." cargo bench echo "Benchmarks complete! 📊" ;; fuzz) if ! command -v cargo-fuzz &> /dev/null; then echo "Error: cargo-fuzz not installed" echo "Install with: cargo install cargo-fuzz" exit 1 fi echo "Running fuzz tests..." echo "" echo "--- Fuzz MVT Parser (60s) ---" cargo fuzz run fuzz_mvt_parser -- -max_total_time=60 echo "" echo "--- Fuzz Overpass Parser (60s) ---" cargo fuzz run fuzz_overpass_parser -- -max_total_time=60 echo "" echo "--- Fuzz Tile Decode (60s) ---" cargo fuzz run fuzz_tile_decode -- -max_total_time=60 echo "" echo "Fuzz tests complete! 🔍" ;; coverage) if ! command -v cargo-tarpaulin &> /dev/null; then echo "Error: cargo-tarpaulin not installed" echo "Install with: cargo install cargo-tarpaulin" exit 1 fi echo "Running tests with coverage..." cargo tarpaulin --out Html --output-dir target/coverage echo "Coverage report generated at target/coverage/tarpaulin-report.html 📊" ;; *) echo "Unknown test type: $TEST_TYPE" echo "" echo "Usage: $0 [all|unit|integration|bench|fuzz|coverage]" exit 1 ;; esac echo "" echo "==========================================" echo "Test run complete!" echo "=========================================="