-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathrun_coverage.sh
More file actions
executable file
·70 lines (56 loc) · 2.03 KB
/
Copy pathrun_coverage.sh
File metadata and controls
executable file
·70 lines (56 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Test Coverage Script for smooth_page_indicator
# This script runs Flutter tests with coverage and generates a report
set -e
echo "🧪 Running Flutter tests with coverage..."
echo "============================================"
# Clean previous coverage data
rm -rf coverage
# Run tests with coverage
flutter test --coverage
echo ""
echo "📊 Coverage data generated!"
echo "============================================"
# Check if lcov is installed
if command -v lcov &> /dev/null; then
echo "📈 Generating HTML coverage report..."
# Generate HTML report
genhtml coverage/lcov.info -o coverage/html --quiet
echo ""
echo "✅ HTML coverage report generated at: coverage/html/index.html"
echo ""
# Open the report in the default browser (macOS)
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "🌐 Opening coverage report in browser..."
open coverage/html/index.html
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "🌐 Opening coverage report in browser..."
xdg-open coverage/html/index.html
fi
else
echo ""
echo "⚠️ lcov is not installed. To generate HTML reports:"
echo " macOS: brew install lcov"
echo " Linux: sudo apt-get install lcov"
echo ""
echo "📄 Raw coverage data is available at: coverage/lcov.info"
fi
echo ""
echo "📋 Coverage Summary:"
echo "============================================"
# Show coverage summary if lcov is available
if command -v lcov &> /dev/null; then
lcov --summary coverage/lcov.info 2>/dev/null || true
else
# Alternative: show line count from lcov.info
if [ -f coverage/lcov.info ]; then
total_lines=$(grep -c "^DA:" coverage/lcov.info 2>/dev/null || echo "0")
covered_lines=$(grep "^DA:" coverage/lcov.info 2>/dev/null | grep -v ",0$" | wc -l || echo "0")
if [ "$total_lines" -gt 0 ]; then
percentage=$((covered_lines * 100 / total_lines))
echo "Lines: $covered_lines / $total_lines ($percentage%)"
fi
fi
fi
echo ""
echo "🎉 Done!"