-
Notifications
You must be signed in to change notification settings - Fork 45
/
coverage.sh
executable file
·51 lines (38 loc) · 1.48 KB
/
coverage.sh
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
#!/usr/bin/env bash
mkdir -p api-coverage/C
mkdir -p api-coverage/Base
mkdir -p api-coverage/Monad
cd api-coverage
# API documentation
curl -s https://z3prover.github.io/api/html/group__capi.html | grep -e "Z3_.*" | sed -e "s/\s//g" | grep -oe "Z3_\\w*</a>(" | grep -oe "Z3_\\w*" | sort | uniq > doc-api.txt
NUM_TOTAL_DOC="$(cat doc-api.txt | wc -l)"
# C API
cat ../src/Z3/Base/C.hsc | grep "foreign import ccall unsafe" | sed -e "s/foreign import ccall unsafe \"\(.*\)\"/\1/g" | sort | uniq > C-api.txt
comm -23 doc-api.txt C-api.txt > C/missing.txt
comm -13 doc-api.txt C-api.txt > C/outdated.txt
function print_coverage {
NUM_MISSING=$1
NUM_TOTAL=$2
NUM_OUTDATED=$3
COV1=$(python3 -c "print(round((1 - $NUM_MISSING/$NUM_TOTAL_DOC)*100, 2))")
echo " Covered: $((NUM_TOTAL_DOC-NUM_MISSING)) / $NUM_TOTAL_DOC ($COV1%)"
if [[ ! -z $2 ]] && [[ ! -z $3 ]]; then
COV2=$(python3 -c "print(round($NUM_OUTDATED/$NUM_TOTAL*100, 2))")
echo " Outdated: $NUM_OUTDATED / $NUM_TOTAL ($COV2%)"
fi
}
echo "C API"
print_coverage $(cat C/missing.txt | wc -l) $(cat C-api.txt | wc -l) $(cat C/outdated.txt | wc -l)
echo "Base API"
expect=$(cat doc-api.txt | sed -e "s/Z3//g" | sed -r 's/(^|_)([a-z])/\U\2/g' | sed -e 's/^./\L&/')
NUM_MISSING=0
for e in $expect; do
grep -q $e ../src/Z3/Base.hs || ((NUM_MISSING=NUM_MISSING+1))
done
print_coverage $NUM_MISSING
echo "Monad API"
NUM_MISSING=0
for e in $expect; do
grep -q $e ../src/Z3/Monad.hs || ((NUM_MISSING=NUM_MISSING+1))
done
print_coverage $NUM_MISSING