summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Orst <andreyorst@gmail.com>2020-10-26 22:50:38 +0300
committerAndrey Orst <andreyorst@gmail.com>2020-10-26 22:50:38 +0300
commiteb5ac9685626493847340274a97a0e99c0231e7b (patch)
tree8ea2fa65c92ef322e76ca486e73203c145ecd388
parent8cc148f7b43d412d378db18d9190d4ea4a537276 (diff)
fix: compensate empty lines in coverage script
Also add it to makefile
-rw-r--r--Makefile3
-rwxr-xr-xcoverage.sh16
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