aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/cover.mk
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-05-11 13:47:51 +0300
committerLoïc Hoguin <[email protected]>2015-05-11 13:48:24 +0300
commit789a4fb6be3bb92380e4314748872ab441ed5554 (patch)
tree28806969fa0a77b19e4d45c0a7372ad451de6b93 /plugins/cover.mk
parent47eb068a47a4a9a079dfeac5e255b979f5df03ab (diff)
downloaderlang.mk-789a4fb6be3bb92380e4314748872ab441ed5554.tar.gz
erlang.mk-789a4fb6be3bb92380e4314748872ab441ed5554.tar.bz2
erlang.mk-789a4fb6be3bb92380e4314748872ab441ed5554.zip
Fix cover tests and use Erlang snippet
Diffstat (limited to 'plugins/cover.mk')
-rw-r--r--plugins/cover.mk59
1 files changed, 31 insertions, 28 deletions
diff --git a/plugins/cover.mk b/plugins/cover.mk
index 3397dca..e94dcd4 100644
--- a/plugins/cover.mk
+++ b/plugins/cover.mk
@@ -101,36 +101,39 @@ EUNIT_HRL_MODS = $(subst $(space),$(comma),$(shell \
grep -e '^\s*-include.*include/eunit\.hrl"' src/*.erl \
| sed "s/^src\/\(.*\)\.erl:.*/'\1'/" | uniq))
+define cover_report.erl
+ $(foreach f,$(COVERDATA),cover:import("$(f)") == ok orelse halt(1),)
+ Ms = cover:imported_modules(),
+ [cover:analyse_to_file(M, "$(COVER_REPORT_DIR)/" ++ atom_to_list(M)
+ ++ ".COVER.html", [html]) || M <- Ms],
+ Report = [begin {ok, R} = cover:analyse(M, module), R end || M <- Ms],
+ EunitHrlMods = [$(EUNIT_HRL_MODS)],
+ Report1 = [{M, {Y, case lists:member(M, EunitHrlMods) of
+ 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)),
+ {ok, F} = file:open("$(COVER_REPORT_DIR)/index.html", [write]),
+ io:format(F, "<!DOCTYPE html><html>~n"
+ "<head><meta charset=\"UTF-8\">~n"
+ "<title>Coverage report</title></head>~n"
+ "<body>~n", []),
+ io:format(F, "<h1>Coverage</h1>~n<p>Total: ~p%</p>~n", [TotalPerc]),
+ 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],
+ How = "$(subst $(space),$(comma)$(space),$(basename $(COVERDATA)))",
+ Date = "$(shell date -u "+%Y-%m-%dT%H:%M:%SZ")",
+ io:format(F, "</table>~n"
+ "<p>Generated using ~s and erlang.mk on ~s.</p>~n"
+ "</body></html>", [How, Date]),
+ halt().
+endef
+
cover-report:
$(gen_verbose) mkdir -p $(COVER_REPORT_DIR)
- $(gen_verbose) $(ERL) -eval ' \
- $(foreach f,$(COVERDATA),cover:import("$(f)") == ok orelse halt(1),) \
- Ms = cover:imported_modules(), \
- [cover:analyse_to_file(M, "$(COVER_REPORT_DIR)/" ++ atom_to_list(M) \
- ++ ".COVER.html", [html]) || M <- Ms], \
- Report = [begin {ok, R} = cover:analyse(M, module), R end || M <- Ms], \
- EunitHrlMods = [$(EUNIT_HRL_MODS)], \
- Report1 = [{M, {Y, case lists:member(M, EunitHrlMods) of \
- 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)), \
- {ok, F} = file:open("$(COVER_REPORT_DIR)/index.html", [write]), \
- io:format(F, "<!DOCTYPE html><html>~n" \
- "<head><meta charset=\"UTF-8\">~n" \
- "<title>Coverage report</title></head>~n" \
- "<body>~n", []), \
- io:format(F, "<h1>Coverage</h1>~n<p>Total: ~p%</p>~n", [TotalPerc]),\
- 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], \
- How = "$(subst $(space),$(comma)$(space),$(basename $(COVERDATA)))", \
- Date = "$(shell date -u "+%Y-%m-%dT%H:%M:%SZ")", \
- io:format(F, "</table>~n" \
- "<p>Generated using ~s and erlang.mk on ~s.</p>~n" \
- "</body></html>", [How, Date]), \
- halt().'
+ $(gen_verbose) $(call erlang,$(cover_report.erl))
endif
endif # ifneq ($(COVER_REPORT_DIR),)