summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoromarkj <omarkj@gmail.com>2014-09-19 00:38:05 -0700
committeromarkj <omarkj@gmail.com>2014-09-19 00:38:05 -0700
commitf9a941f2da1cd2667709323f456f4866902a2e79 (patch)
treed994bb50e5485c6ffce769072fae58c9234415d6 /src
parentf3b5adfb717b90eaa2d1ba634b79c323a0e09c8a (diff)
Enable ct.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_common_test.erl43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index a8d7e31..958822f 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -32,23 +32,29 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(State) ->
- % Run common tests.
- % CommandArguments = rebar_state:command_args(State),
+ Opts = build_options(State),
+ ct:run_test(Opts),
+ {ok, State}.
+
+build_options(State) ->
+ Arguments = rebar_state:command_args(State),
+ Opts = parse_args(Arguments, []),
+ lists:keymerge(1, Opts, defaults(State)).
+
+defaults(State) ->
Logdir = filename:join([rebar_state:dir(State), "logs"]),
ok = ensure_logdir(Logdir),
- % @todo check for test dir, figure out how Tristan does nice errors
Testdir = filename:join([rebar_state:dir(State), "test"]),
- case ec_file:is_dir(Testdir) of
- false ->
- ?INFO("Test directory ~s does not exist:\n",
- [Testdir]),
- ?FAIL;
- _ -> ok
- end,
- Opts = [{dir, Testdir},
- {logdir, Logdir}],
- ct:run_test(Opts),
- {ok, State}.
+ ok = ensure_testdir(Testdir),
+ [{dir, Testdir},
+ {logdir, Logdir}].
+
+parse_args([], Opts) ->
+ Opts;
+parse_args([Pair|Rest], Opts) ->
+ [Key, Val] = string:tokens(Pair, "="),
+ Key0 = list_to_atom(Key),
+ parse_args(Rest, [{Key0, string:tokens(Val, " ")}|Opts]).
ensure_logdir(Logdir) ->
case ec_file:is_dir(Logdir) of
@@ -57,3 +63,12 @@ ensure_logdir(Logdir) ->
false ->
ec_file:mkdir_path(Logdir)
end.
+
+ensure_testdir(Testdir) ->
+ case ec_file:is_dir(Testdir) of
+ false ->
+ ?INFO("Test directory ~s does not exist:\n",
+ [Testdir]),
+ ?FAIL;
+ _ -> ok
+ end.