Permalink
Browse files

Merge pull request #4 from michalwski/master

cover summary for all tests runs
  • Loading branch information...
2 parents 04623c9 + baa27da commit 4eaaa6741f9f17f416bf0b63695673bc5892ca00 @goj goj committed May 31, 2012
Showing with 67 additions and 17 deletions.
  1. +31 −7 Makefile
  2. +36 −10 run_common_test.erl
View
@@ -1,16 +1,15 @@
-.PHONY: all test console
+.PHONY: all test console compile
all: test
test_clean: escalus/Makefile
rm -rf tests/*.beam
make test
-test: escalus/Makefile
- cd escalus; make
- erlc -Iescalus/deps/exml/include \
- -Iescalus/deps/lxmppc/include \
- run_common_test.erl
- mkdir -p ct_report
+cover_test_clean: escalus/Makefile
+ rm -rf tests/*.beam
+ make cover_test
+
+test: escalus/Makefile prepare
erl -noinput -sname test -setcookie ejabberd \
-pa `pwd`/tests \
`pwd`/escalus/ebin \
@@ -19,6 +18,31 @@ test: escalus/Makefile
`pwd`/escalus/deps/base16/ebin \
-s run_common_test ct
+cover_test: escalus/Makefile prepare
+ erl -noinput -sname test -setcookie ejabberd \
+ -pa `pwd`/tests \
+ `pwd`/escalus/ebin \
+ `pwd`/escalus/deps/exml/ebin \
+ `pwd`/escalus/deps/lxmppc/ebin \
+ `pwd`/escalus/deps/base16/ebin \
+ -s run_common_test ct_cover
+
+cover_summary: escalus/Makefile prepare
+ erl -noinput -sname test -setcookie ejabberd \
+ -pa `pwd`/tests \
+ `pwd`/escalus/ebin \
+ `pwd`/escalus/deps/exml/ebin \
+ `pwd`/escalus/deps/lxmppc/ebin \
+ `pwd`/escalus/deps/base16/ebin \
+ -s run_common_test cover_summary
+
+prepare:
+ cd escalus; make
+ erlc -Iescalus/deps/exml/include \
+ -Iescalus/deps/lxmppc/include \
+ run_common_test.erl
+ mkdir -p ct_report
+
console: escalus/Makefile
cd escalus; make
erl -sname test -setcookie ejabberd \
View
@@ -1,5 +1,5 @@
-module(run_common_test).
--export([ct/0, ct_cover/0]).
+-export([ct/0, ct_cover/0, cover_summary/0]).
-define(CT_DIR, filename:join([".", "tests"])).
-define(CT_REPORT, filename:join([".", "ct_report"])).
@@ -19,27 +19,53 @@ ct() ->
init:stop(0).
ct_cover() ->
- cover_call(start),
- cover_call(compile_beam_directory,["lib/ejabberd-2.1.8/ebin"]),
- %% io:format("Compiled modules ~p~n", [Compiled]),
+ prepare(),
ct:run_test([
{config, [?CT_CONFIG]},
{dir, ?CT_DIR},
- {logdir, ?CT_REPORT},
- {suite, login_SUITE}
+ {logdir, ?CT_REPORT}
]),
+ analyze(),
+ {MS,S,_} = now(),
+ FileName = lists:flatten(io_lib:format("run_~b~b.coverdata",[MS,S])),
+ io:format("export current cover ~p~n", [cover_call(export, [FileName])]),
+ io:format("test finished~n"),
+
+ init:stop(0).
+
+cover_summary() ->
+ prepare(),
+ Files = rpc:call(?EJABBERD_NODE, filelib, wildcard, ["*.coverdata"]),
+ lists:foreach(fun(F) ->
+ io:format("import ~p cover ~p~n", [F, cover_call(import, [F])])
+ end,
+ Files),
+ analyze(),
+ io:format("summary completed~n"),
+ init:stop(0).
+
+prepare() ->
+ %%rpc:call(?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("Compiled modules ~p~n", [Compiled]).
+ %%timer:sleep(10000).
+
+analyze() ->
Modules = cover_call(modules),
rpc:call(?EJABBERD_NODE, file, make_dir, ["coverage"]),
+ {ok, File} = file:open("cover_summary.txt", write),
Fun = fun(Module) ->
- Stats = cover_call(analyse, [Module, module]),
FileName = lists:flatten(io_lib:format("~s.COVER.html",[Module])),
FilePath = filename:join(["coverage", FileName]),
cover_call(analyse_to_file, [Module, FilePath, [html]]),
- io:format("~p ~p~n", [Module, Stats])
+ {ok, {Module, {C, NC}}} = cover_call(analyse, [Module, module]),
+ io:fwrite(File, "~s;~b;~b;~s\n", [Module, C, NC, FilePath])
end,
+ io:format("coverage analyzing~n"),
lists:foreach(Fun, Modules),
- %% io:format("modules ~p~n", Modules),
- init:stop(0).
+ file:close(File).
cover_call(Function) ->
cover_call(Function, []).

0 comments on commit 4eaaa67

Please sign in to comment.