aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/cover.mk5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/cover.mk b/plugins/cover.mk
index 41a0c45..36d21fd 100644
--- a/plugins/cover.mk
+++ b/plugins/cover.mk
@@ -93,7 +93,8 @@ define cover_report.erl
true -> N - 1; false -> N end}} || {M, {Y, N}} <- Report],
TotalY = lists:sum([Y || {_, {Y, _}} <- Report1]),
TotalN = lists:sum([N || {_, {_, N}} <- Report1]),
- TotalPerc = round(100 * TotalY / (TotalY + TotalN)),
+ Perc = fun(Y, N) -> case Y + N of 0 -> 100; S -> round(100 * Y / S) end end,
+ TotalPerc = Perc(TotalY, TotalN),
{ok, F} = file:open("$(COVER_REPORT_DIR)/index.html", [write]),
io:format(F, "<!DOCTYPE html><html>~n"
"<head><meta charset=\"UTF-8\">~n"
@@ -103,7 +104,7 @@ define cover_report.erl
io:format(F, "<table><tr><th>Module</th><th>Coverage</th></tr>~n", []),
[io:format(F, "<tr><td><a href=\"~p.COVER.html\">~p</a></td>"
"<td>~p%</td></tr>~n",
- [M, M, round(100 * Y / (Y + N))]) || {M, {Y, N}} <- Report1],
+ [M, M, Perc(Y, N)]) || {M, {Y, N}} <- Report1],
How = "$(subst $(space),$(comma)$(space),$(basename $(COVERDATA)))",
Date = "$(shell date -u "+%Y-%m-%dT%H:%M:%SZ")",
io:format(F, "</table>~n"