Skip to content

Commit ef04dd7

Browse files
committed
Add Coveralls support
1 parent 3441157 commit ef04dd7

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ before_install:
2222
- sudo apt-get -qq update
2323
- sudo apt-get -qq -o Dpkg::Options::=--force-confold install mysql-server-5.6
2424
# /END MYSQL 5.6
25-
25+
- pip install --user cpp-coveralls coveralls-merge
2626

2727
install:
2828
- sudo apt-get -qq install libexpat1-dev libyaml-dev libpam0g-dev libsqlite3-dev
@@ -57,5 +57,9 @@ after_script:
5757
after_failure:
5858
- find logs -name ejabberd.log -exec cat '{}' ';'
5959

60+
after_success:
61+
- coveralls --exclude lib --exclude tests --gcov-options '\-lp' --dump c.json
62+
- coveralls-merge c.json erlang.json
63+
6064
notifications:
6165
email: false

cover.spec

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{level, details}.
2+
{incl_dirs, ["src", "ebin"]}.
3+
{excl_mods, [eldap, 'ELDAPv3']}.
4+
{export, "logs/all.coverdata"}.
5+

rebar.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767

6868
{erl_opts, [nowarn_deprecated_function,
6969
{if_var_false, debug, no_debug_info},
70+
{if_var_true, debug, debug_info},
7071
{if_var_true, roster_gateway_workaround, {d, 'ROSTER_GATWAY_WORKAROUND'}},
7172
{if_var_match, db_type, mssql, {d, 'mssql'}},
7273
{if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}},
@@ -111,6 +112,9 @@
111112

112113
{eunit_compile_opts, [{i, "tools"}]}.
113114

115+
{cover_enabled, true}.
116+
{cover_export_enabled, true}.
117+
114118
{post_hook_configure, [{"fast_tls", []},
115119
{"stringprep", []},
116120
{"fast_yaml", []},

rebar.config.script

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
%%% Created : 1 May 2013 by Evgeniy Khramtsov <[email protected]>
88
%%%-------------------------------------------------------------------
99

10+
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
11+
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
12+
{value, {_, V1}, V2} -> {V1, V2};
13+
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
14+
end,
15+
case Tail of
16+
[] ->
17+
[{Key, Op(OldVal)} | PartCfg];
18+
_ ->
19+
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
20+
end
21+
end,
22+
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end.
23+
1024
Cfg = case file:consult(filename:join(filename:dirname(SCRIPT), "vars.config")) of
1125
{ok, Terms} ->
1226
Terms;
@@ -107,9 +121,20 @@ Conf5 = case lists:keytake(floating_deps, 1, Conf3) of
107121
Conf3
108122
end,
109123

124+
%% When running Travis test, upload test coverage result to coveralls:
125+
Conf6 = case os:getenv("TRAVIS") of
126+
"true" ->
127+
JobId = os:getenv("TRAVIS_JOB_ID"),
128+
CfgTemp = ModCfg(Conf5, [deps], fun(V) -> [{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}|V] end, []),
129+
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"},
130+
{ct, "escript ./getcover.erl"}] end, []);
131+
_ ->
132+
Conf5
133+
end,
134+
110135
%io:format("ejabberd configuration:~n ~p~n", [Conf5]),
111136

112-
Conf5.
137+
Conf6.
113138

114139
%% Local Variables:
115140
%% mode: erlang

0 commit comments

Comments
 (0)