Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 6 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on May 31, 2012
@erszcz erszcz Avoid configuration redundancy ef8f053
@erszcz erszcz Always generate HTML coverage report e10ea0b
Commits on Jun 01, 2012
@erszcz erszcz Fix report generation
In case of no executable line in a file the report generation failed.
It reports 100 percent coverage in such a case now :)
a683cdb
Commits on Jun 14, 2012
@erszcz erszcz cover summary: link to sources in dev instead of rel bf9eeb9
@erszcz erszcz Cleanup run_common_test.erl a9f9490
@goj goj Merge pull request #5 from esl/coverage-report
Always generate HTML coverage report
a636940
Showing with 65 additions and 16 deletions.
  1. +4 −2 Makefile
  2. +43 −0 make_cover_summary.rb
  3. +18 −14 run_common_test.erl
View
6 Makefile
@@ -25,7 +25,8 @@ cover_test: escalus/Makefile prepare
`pwd`/escalus/deps/exml/ebin \
`pwd`/escalus/deps/lxmppc/ebin \
`pwd`/escalus/deps/base16/ebin \
- -s run_common_test ct_cover
+ -s run_common_test ct_cover; \
+ ./make_cover_summary.rb
cover_summary: escalus/Makefile prepare
erl -noinput -sname test -setcookie ejabberd \
@@ -34,7 +35,8 @@ cover_summary: escalus/Makefile prepare
`pwd`/escalus/deps/exml/ebin \
`pwd`/escalus/deps/lxmppc/ebin \
`pwd`/escalus/deps/base16/ebin \
- -s run_common_test cover_summary
+ -s run_common_test cover_summary; \
+ ./make_cover_summary.rb
prepare:
cd escalus; make
View
43 make_cover_summary.rb
@@ -0,0 +1,43 @@
+#!/usr/bin/env ruby
+
+$summary = "ct_report/cover.html"
+$summary_data = "cover_summary.txt"
+
+def make_cover_summary()
+ open($summary, "w") do |cover|
+ cover.write("<html>\n<head></head>\n<body bgcolor=\"white\" text=\"black\" link=\"blue\" vlink=\"purple\" alink=\"red\">\n")
+ cover.write("<h1>Coverage for application 'omp'</h1>\n")
+ cover.write("<table border=3 cellpadding=5>\n")
+ cover.write("<tr><th>Module</th><th>Covered (%)</th><th>Covered (Lines)</th><th>Not covered (Lines)</th>")
+ sum = open($summary_data, "r")
+ c_sum = 0
+ nc_sum = 0;
+ while (line = sum.gets)
+ cells = line.split(/;/)
+ cover.write("<tr>")
+ cover.write("<td><a href='../../dev/ejabberd/#{cells[3]}'>#{cells[0]}</a></td>")
+ c = cells[1].to_f
+ nc = cells[2].to_f
+ p = if c != 0 or nc != 0 then c/(nc+c)*100 else 100 end
+ c_sum = c_sum + c
+ nc_sum = nc_sum + nc
+ cover.write("<td>#{p.round} %</td>")
+ cover.write("<td>#{cells[1]}</td>")
+ cover.write("<td>#{cells[2]}</td>")
+ cover.write("</tr>\n")
+ end
+ p = c_sum/(nc_sum + c_sum) * 100
+ cover.write("<tr>")
+ cover.write("<td>Summary</td>")
+ cover.write("<td>#{p.round} %</td>")
+ cover.write("<td>#{c_sum.round}</td>")
+ cover.write("<td>#{nc_sum.round}</td>")
+ cover.write("</tr>\n")
+ cover.write("</table>\n</body>\n</html>")
+ cover.close
+ end
+end
+
+if __FILE__ == $0
+ make_cover_summary()
+end
View
32 run_common_test.erl
@@ -4,12 +4,15 @@
-define(CT_DIR, filename:join([".", "tests"])).
-define(CT_REPORT, filename:join([".", "ct_report"])).
-define(CT_CONFIG, "test.config").
--define(EJABBERD_NODE, 'ejabberd@localhost').
+
+tests_to_run() -> [
+ {config, [?CT_CONFIG]},
+ {dir, ?CT_DIR},
+ {logdir, ?CT_REPORT}
+ ].
ct() ->
- Result = ct:run_test([{config, [?CT_CONFIG]},
- {dir, ?CT_DIR},
- {logdir, ?CT_REPORT}]),
+ Result = ct:run_test(tests_to_run()),
case Result of
{error, Reason} ->
throw({ct_error, Reason});
@@ -20,11 +23,7 @@ ct() ->
ct_cover() ->
prepare(),
- ct:run_test([
- {config, [?CT_CONFIG]},
- {dir, ?CT_DIR},
- {logdir, ?CT_REPORT}
- ]),
+ ct:run_test(tests_to_run()),
analyze(),
{MS,S,_} = now(),
FileName = lists:flatten(io_lib:format("run_~b~b.coverdata",[MS,S])),
@@ -35,7 +34,7 @@ ct_cover() ->
cover_summary() ->
prepare(),
- Files = rpc:call(?EJABBERD_NODE, filelib, wildcard, ["*.coverdata"]),
+ Files = rpc:call(get_ejabberd_node(), filelib, wildcard, ["*.coverdata"]),
lists:foreach(fun(F) ->
io:format("import ~p cover ~p~n", [F, cover_call(import, [F])])
end,
@@ -45,16 +44,16 @@ cover_summary() ->
init:stop(0).
prepare() ->
- %%rpc:call(?EJABBERD_NODE, application, stop, [ejabberd]),
+ %%rpc:call(get_ejabberd_node(), application, stop, [ejabberd]),
cover_call(start),
Compiled = cover_call(compile_beam_directory,["lib/ejabberd-2.1.8/ebin"]),
- %%io:format("start ~p~n", [rpc:call(?EJABBERD_NODE, application, start, [ejabberd, permanent])]),
+ %%io:format("start ~p~n", [rpc:call(get_ejabberd_node(), application, start, [ejabberd, permanent])]),
io:format("Compiled modules ~p~n", [Compiled]).
%%timer:sleep(10000).
analyze() ->
Modules = cover_call(modules),
- rpc:call(?EJABBERD_NODE, file, make_dir, ["coverage"]),
+ rpc:call(get_ejabberd_node(), file, make_dir, ["coverage"]),
{ok, File} = file:open("cover_summary.txt", write),
Fun = fun(Module) ->
FileName = lists:flatten(io_lib:format("~s.COVER.html",[Module])),
@@ -70,4 +69,9 @@ analyze() ->
cover_call(Function) ->
cover_call(Function, []).
cover_call(Function, Args) ->
- rpc:call(?EJABBERD_NODE, cover, Function, Args).
+ rpc:call(get_ejabberd_node(), cover, Function, Args).
+
+get_ejabberd_node() ->
+ {ok, Props} = file:consult("test.config"),
+ {ejabberd_node, Node} = proplists:lookup(ejabberd_node, Props),
+ Node.

No commit comments for this range

Something went wrong with that request. Please try again.