diff options
author | Mickael Remond <mremond@process-one.net> | 2016-03-21 12:01:20 +0100 |
---|---|---|
committer | Mickael Remond <mremond@process-one.net> | 2016-03-21 12:01:20 +0100 |
commit | ef04dd75aa91793cd5fb8c87265c0b5214e0b575 (patch) | |
tree | 971550dad66886a2636ffbeee2d2d0b0f99c5d61 | |
parent | Use static key for mysql repo (diff) |
Add Coveralls support
-rw-r--r-- | .travis.yml | 6 | ||||
-rw-r--r-- | cover.spec | 5 | ||||
-rw-r--r-- | rebar.config | 4 | ||||
-rw-r--r-- | rebar.config.script | 27 |
4 files changed, 40 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml index 92154cf5..a0c1d0bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ before_install: - sudo apt-get -qq update - sudo apt-get -qq -o Dpkg::Options::=--force-confold install mysql-server-5.6 # /END MYSQL 5.6 - + - pip install --user cpp-coveralls coveralls-merge install: - sudo apt-get -qq install libexpat1-dev libyaml-dev libpam0g-dev libsqlite3-dev @@ -57,5 +57,9 @@ after_script: after_failure: - 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: email: false diff --git a/cover.spec b/cover.spec new file mode 100644 index 00000000..7d504d55 --- /dev/null +++ b/cover.spec @@ -0,0 +1,5 @@ +{level, details}. +{incl_dirs, ["src", "ebin"]}. +{excl_mods, [eldap, 'ELDAPv3']}. +{export, "logs/all.coverdata"}. + diff --git a/rebar.config b/rebar.config index 1f064dd5..d4dac434 100644 --- a/rebar.config +++ b/rebar.config @@ -67,6 +67,7 @@ {erl_opts, [nowarn_deprecated_function, {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_match, db_type, mssql, {d, 'mssql'}}, {if_var_true, erlang_deprecated_types, {d, 'ERL_DEPRECATED_TYPES'}}, @@ -111,6 +112,9 @@ {eunit_compile_opts, [{i, "tools"}]}. +{cover_enabled, true}. +{cover_export_enabled, true}. + {post_hook_configure, [{"fast_tls", []}, {"stringprep", []}, {"fast_yaml", []}, diff --git a/rebar.config.script b/rebar.config.script index a7120b12..90928420 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -7,6 +7,20 @@ %%% 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 {ok, Terms} -> Terms; @@ -107,9 +121,20 @@ Conf5 = case lists:keytake(floating_deps, 1, Conf3) of Conf3 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]), -Conf5. +Conf6. %% Local Variables: %% mode: erlang |