diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rwxr-xr-x | coverage.sh | 16 |
2 files changed, 16 insertions, 3 deletions
@@ -17,6 +17,9 @@ test: @fennel core_test.fnl @fennel macros_test.fnl +test-coverage: + @sh coverage.sh + coverage: | clean all luacov-stats luacov diff --git a/coverage.sh b/coverage.sh index 23c5c31..c66d2af 100755 --- a/coverage.sh +++ b/coverage.sh @@ -7,10 +7,20 @@ tsts=$( grep -o "(testing $fn[^ ]*" core_test.fnl macros_test.fnl | cut -f2 --delimiter=" " done ) -not_tested=$(printf "%s\n%s" "$fns" "$tsts" | sort | uniq -u) +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 -total_fns=$(printf "%s" "$fns" | wc -l) -total_not_tested=$(printf "%s" "$not_tested" | wc -l) coverage=$((100 - (("$total_not_tested" * 100) / "$total_fns"))) echo "test coverage: $coverage%" >&2 |