Skip to content

Commit

Permalink
Avoid configuration redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed May 31, 2012
1 parent 4eaaa67 commit ef8f053
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions run_common_test.erl
Expand Up @@ -4,12 +4,16 @@
-define(CT_DIR, filename:join([".", "tests"])).
-define(CT_REPORT, filename:join([".", "ct_report"])).
-define(CT_CONFIG, "test.config").
-define(EJABBERD_NODE, 'ejabberd@localhost').
-define(EJABBERD_NODE, get_ejabberd_node()).

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});
Expand All @@ -20,11 +24,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])),
Expand Down Expand Up @@ -71,3 +71,13 @@ cover_call(Function) ->
cover_call(Function, []).
cover_call(Function, Args) ->
rpc:call(?EJABBERD_NODE, cover, Function, Args).

get_ejabberd_node() ->
case get(ejabberd_node) of
undefined ->
{ok, Props} = file:consult("test.config"),
{ejabberd_node, Node} = proplists:lookup(ejabberd_node, Props),
Node;
Node ->
Node
end.

0 comments on commit ef8f053

Please sign in to comment.