From eb5ac9685626493847340274a97a0e99c0231e7b Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Mon, 26 Oct 2020 22:50:38 +0300 Subject: fix: compensate empty lines in coverage script Also add it to makefile --- Makefile | 3 +++ coverage.sh | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c4c331b..f48a608 100644 --- a/Makefile +++ b/Makefile @@ -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 -- cgit v1.2.3