Add Coveralls support

This commit is contained in:
Mickael Remond 2016-03-21 12:01:20 +01:00
parent 3441157a38
commit ef04dd75aa
4 changed files with 40 additions and 2 deletions

View File

@ -22,7 +22,7 @@ before_install:
- sudo apt-get -qq update - sudo apt-get -qq update
- sudo apt-get -qq -o Dpkg::Options::=--force-confold install mysql-server-5.6 - sudo apt-get -qq -o Dpkg::Options::=--force-confold install mysql-server-5.6
# /END MYSQL 5.6 # /END MYSQL 5.6
- pip install --user cpp-coveralls coveralls-merge
install: install:
- sudo apt-get -qq install libexpat1-dev libyaml-dev libpam0g-dev libsqlite3-dev - sudo apt-get -qq install libexpat1-dev libyaml-dev libpam0g-dev libsqlite3-dev
@ -57,5 +57,9 @@ after_script:
after_failure: after_failure:
- find logs -name ejabberd.log -exec cat '{}' ';' - find logs -name ejabberd.log -exec cat '{}' ';'
after_success:
- coveralls --exclude lib --exclude tests --gcov-options '\-lp' --dump c.json
- coveralls-merge c.json erlang.json
notifications: notifications:
email: false email: false

5
cover.spec Normal file
View File

@ -0,0 +1,5 @@
{level, details}.
{incl_dirs, ["src", "ebin"]}.
{excl_mods, [eldap, 'ELDAPv3']}.
{export, "logs/all.coverdata"}.

View File

@ -67,6 +67,7 @@
{erl_opts, [nowarn_deprecated_function, {erl_opts, [nowarn_deprecated_function,
{if_var_false, debug, no_debug_info}, {if_var_false, debug, no_debug_info},
{if_var_true, debug, debug_info},
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}}, {if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
{if_var_match, db_type, mssql, {d, 'mssql'}}, {if_var_match, db_type, mssql, {d, 'mssql'}},
{if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}}, {if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}},
@ -111,6 +112,9 @@
{eunit_compile_opts, [{i, "tools"}]}. {eunit_compile_opts, [{i, "tools"}]}.
{cover_enabled, true}.
{cover_export_enabled, true}.
{post_hook_configure, [{"fast_tls", []}, {post_hook_configure, [{"fast_tls", []},
{"stringprep", []}, {"stringprep", []},
{"fast_yaml", []}, {"fast_yaml", []},

View File

@ -7,6 +7,20 @@
%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
{value, {_, V1}, V2} -> {V1, V2};
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
end,
case Tail of
[] ->
[{Key, Op(OldVal)} | PartCfg];
_ ->
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
end
end,
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end.
Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config")) of Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config")) of
{ok, Terms} -> {ok, Terms} ->
Terms; Terms;
@ -107,9 +121,20 @@ Conf5 = case lists:keytake(floating_deps, 1, Conf3) of
Conf3 Conf3
end, end,
%% When running Travis test, upload test coverage result to coveralls:
Conf6 = case os:getenv("TRAVIS") of
"true" ->
JobId = os:getenv("TRAVIS_JOB_ID"),
CfgTemp = ModCfg(Conf5, [deps], fun(V) -> [{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}|V] end, []),
ModCfg(CfgTemp, [post_hooks], fun(V) -> V ++ [{ct, "echo '\n%%! -pa ebin/ deps/coveralls/ebin\nmain(_)->{ok,F}=file:open(\"erlang.json\",[write]),io:fwrite(F,\"~s\",[coveralls:convert_file(\"logs/all.coverdata\", \""++JobId++"\", \"travis-ci\")]).' > getcover.erl"},
{ct, "escript ./getcover.erl"}] end, []);
_ ->
Conf5
end,
%io:format("ejabberd configuration:~n ~p~n", [Conf5]), %io:format("ejabberd configuration:~n ~p~n", [Conf5]),
Conf5. Conf6.
%% Local Variables: %% Local Variables:
%% mode: erlang %% mode: erlang