summaryrefslogtreecommitdiff
path: root/coverage.sh
blob: c66d2afdb0db517a6afedc15dffa968e1a56606b (plain) (blame)
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
#!/bin/env sh

fns=$(grep "^(fn" core.fnl macros/core.fnl | cut -f2 --delimiter=" " | grep -v "^-")
tsts=$(
    for fn in $fns; do
        fn=$(echo "$fn" | sed "s/\?/\\\?/")
        grep -o "(testing $fn[^ ]*" core_test.fnl macros_test.fnl | cut -f2 --delimiter=" "
    done
    )
not_tested=$(printf "%s\n%s\n" "$fns" "$tsts" | sort | uniq -u)

if [ -z "$fns" ]; then
    total_fns=0
else
    total_fns=$(printf "%s\n" "$fns" | wc -l)
fi

if [ -z "$not_tested" ]; then
    total_not_tested=0
else
    total_not_tested=$(printf "%s\n" "$not_tested" | wc -l)
fi

coverage=$((100 - (("$total_not_tested" * 100) / "$total_fns")))

echo "test coverage: $coverage%" >&2

if [ $coverage -ne 100 ]; then
    echo "not tested functions:" >&2
    echo "$not_tested" | tr '\n' ' ' >&2
    echo >&2
    exit 1
fi