-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.sh
More file actions
executable file
·90 lines (74 loc) · 2.01 KB
/
coverage.sh
File metadata and controls
executable file
·90 lines (74 loc) · 2.01 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
#!/bin/bash
# Simple test coverage analysis for NimCode
# Analyzes which public procs are covered by tests
set -e
echo "=== NimCode Test Coverage Analysis ==="
echo ""
# Source modules to analyze
MODULES=(
"src/nimcode/tui/tui.nim"
"src/nimcode/tui/input.nim"
"src/nimcode/tui/statusbar.nim"
"src/nimcode/cli/stream.nim"
)
# Test files
TESTS=(
"tests/test_tui.nim"
"tests/test_statusbar.nim"
"tests/test_stream.nim"
"tests/test_input.nim"
)
total_procs=0
tested_procs=0
for module in "${MODULES[@]}"; do
if [ ! -f "$module" ]; then
continue
fi
module_name=$(basename "$module" .nim)
echo "--- $module_name ---"
# Extract public proc names (starting with lowercase after proc)
procs=$(grep -E "^proc \w+\*" "$module" 2>/dev/null | sed 's/proc \([a-zA-Z0-9_]*\).*/\1/' || true)
if [ -z "$procs" ]; then
echo " No public procs found"
echo ""
continue
fi
module_total=0
module_tested=0
while IFS= read -r proc_name; do
if [ -z "$proc_name" ]; then
continue
fi
module_total=$((module_total + 1))
total_procs=$((total_procs + 1))
# Check if proc is referenced in any test file
found=false
for test_file in "${TESTS[@]}"; do
if [ -f "$test_file" ] && grep -q "$proc_name" "$test_file" 2>/dev/null; then
found=true
break
fi
done
if [ "$found" = true ]; then
echo " ✓ $proc_name"
module_tested=$((module_tested + 1))
tested_procs=$((tested_procs + 1))
else
echo " ✗ $proc_name"
fi
done <<< "$procs"
if [ $module_total -gt 0 ]; then
coverage=$((module_tested * 100 / module_total))
echo " Coverage: $module_tested/$module_total ($coverage%)"
fi
echo ""
done
echo "=== Summary ==="
if [ $total_procs -gt 0 ]; then
overall_coverage=$((tested_procs * 100 / total_procs))
echo "Total public procs: $total_procs"
echo "Tested procs: $tested_procs"
echo "Overall coverage: $overall_coverage%"
else
echo "No public procs found to analyze"
fi