aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-03-19 12:38:40 +0100
committerLoïc Hoguin <[email protected]>2016-03-19 12:38:40 +0100
commit1fee577a15f5dbcc391b8f555458dad68f24afde (patch)
tree4744696587de2f4351d13c38042e7e8dae20fe86
parent880b27b372b0039ca27dacd7c8f18431d5bcfb3e (diff)
parentd1cf84781495ab26fe14424cc937c51bdcae3819 (diff)
downloaderlang.mk-1fee577a15f5dbcc391b8f555458dad68f24afde.tar.gz
erlang.mk-1fee577a15f5dbcc391b8f555458dad68f24afde.tar.bz2
erlang.mk-1fee577a15f5dbcc391b8f555458dad68f24afde.zip
Merge branch 'cover_badarith_fix' of https://github.com/hdima/erlang.mk
-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"