-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcoverage.sh
More file actions
executable file
·96 lines (85 loc) · 2.54 KB
/
coverage.sh
File metadata and controls
executable file
·96 lines (85 loc) · 2.54 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
set -e
# Crypto features to test
CRYPTO_FEATURES=("native_crypto" "openssl_crypto")
PROMPTERS=("gnome" "plasma")
mkdir -p coverage-raw
# Test oo7 package with all crypto features
for crypto in "${CRYPTO_FEATURES[@]}"; do
echo "🧪 Generating coverage for oo7::${crypto}/tokio..."
cargo tarpaulin \
--package oo7 \
--no-default-features \
--features "tracing,tokio,${crypto}" \
--ignore-panics \
--out Lcov \
--output-dir coverage-raw
mv coverage-raw/lcov.info "coverage-raw/${crypto}-tokio.info"
echo ""
done
# Test daemon with all prompter/crypto combinations
for prompter in "${PROMPTERS[@]}"; do
for crypto in "${CRYPTO_FEATURES[@]}"; do
echo ""
echo "🧪 Generating coverage for oo7-daemon::${prompter}_${crypto}..."
OO7_DAEMON_PROMPTER_TEST="${prompter}" cargo tarpaulin \
--package oo7-daemon \
--no-default-features \
--features "${crypto}" \
--ignore-panics \
--out Lcov \
--output-dir coverage-raw
mv coverage-raw/lcov.info "coverage-raw/daemon-${prompter}_${crypto}.info"
done
done
echo ""
echo "📊 Merging coverage reports..."
mkdir -p coverage/html
# Merge LCOV files
cat coverage-raw/*.info > coverage-raw/combined.info
# Generate JSON report with grcov
grcov coverage-raw/combined.info \
--binary-path target/debug/ \
--source-dir . \
--output-type covdir \
--output-path coverage/coverage.json \
--branch \
--ignore-not-existing \
--ignore "**/portal/*" \
--ignore "**/python/*" \
--ignore "**/cli/*" \
--ignore "**/pam/*" \
--ignore "**/tests/*" \
--ignore "**/examples/*" \
--ignore "**/target/*" \
--ignore "**/error.rs"
# Generate HTML report with grcov
grcov coverage-raw/combined.info \
--binary-path target/debug/ \
--source-dir . \
--output-type html \
--output-path coverage \
--branch \
--ignore-not-existing \
--ignore "**/portal/*" \
--ignore "**/python/*" \
--ignore "**/cli/*" \
--ignore "**/pam/*" \
--ignore "**/tests/*" \
--ignore "**/examples/*" \
--ignore "**/target/*" \
--ignore "**/error.rs"
# Extract and display coverage percentage
if [ -f coverage/html/coverage.json ]; then
COVERAGE=$(jq -r '.message' coverage/html/coverage.json | sed 's/%//')
echo ""
echo "✅ Combined coverage: ${COVERAGE}%"
echo "📁 HTML report available at: coverage/html/index.html"
echo "📁 JSON report available at: coverage/coverage.json"
else
echo "⚠️ Warning: coverage.json not found"
fi
# Clean up raw files
rm -rf coverage-raw
echo ""
echo "🎉 Coverage generation complete!"