summaryrefslogtreecommitdiff
path: root/coverage.sh
diff options
context:
space:
mode:
authorAndrey Orst <andreyorst@gmail.com>2020-10-26 21:46:54 +0300
committerAndrey Orst <andreyorst@gmail.com>2020-10-26 21:46:54 +0300
commit3ef9b8f888bf2dda7ce690a84a60bbade0223933 (patch)
tree6cccb5b4d469f62128205352222789768eee513a /coverage.sh
parent1d2bba82b09710b0dc6ca4e1a515763088b3fbf5 (diff)
feature(testing): group tests, update coverage script
Diffstat (limited to 'coverage.sh')
-rwxr-xr-xcoverage.sh23
1 files changed, 16 insertions, 7 deletions
diff --git a/coverage.sh b/coverage.sh
index f5b0371..23c5c31 100755
--- a/coverage.sh
+++ b/coverage.sh
@@ -1,14 +1,23 @@
#!/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 "(test $fn" core_test.fnl macros_test.fnl | cut -f2 --delimiter=" "; done)
+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" "$fns" "$tsts" | sort | uniq -u)
-total_fns=$(echo "$fns" | wc -l)
-total_not_tested=$(echo "$not_tested" | wc -l)
+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 "coverage: $coverage%" >&2
-echo "not tested functions:" >&2
-echo "$not_tested" | tr '\n' ' ' >&2
-echo >&2
+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