summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-11-13 14:13:59 +0000
committerFred Hebert <mononcqc@ferd.ca>2015-11-13 14:13:59 +0000
commitd31e663a67a483b6a740f973f52db41fd01e5861 (patch)
tree686c5dba9f0659f3c44cbc37bc472db19e868982 /src
parentb137a070df67866c4449c8bc977a3d6eae4d0e7f (diff)
Prettify all of common test output.
This uses cth_readable to: - silence error_logger output to the shell unless a test fails - silence ct:pal output to the shell unless a test fails I have currently not baked in any way to disable this behaviour, but I figured if it is required, there is time to do it before the final 3.0.0 release.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_common_test.erl21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index 977a5f6..525ddaf 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -152,7 +152,7 @@ split_string(String) ->
cfgopts(State) ->
Opts = rebar_state:get(State, ct_opts, []),
- rebar_utils:filtermap(fun filter_opts/1, Opts).
+ add_hooks(rebar_utils:filtermap(fun filter_opts/1, Opts)).
filter_opts({test_spec, _}) ->
?WARN("Test specs not supported", []),
@@ -170,6 +170,18 @@ filter_opts({suite, Suites}) ->
Suites)}};
filter_opts(_) -> true.
+add_hooks(Opts) ->
+ %% cth_readable hooks
+ case lists:keyfind(ct_hooks, 1, Opts) of
+ false ->
+ [{ct_hooks, [cth_readable_failonly, cth_readable_shell]} | Opts];
+ {ct_hooks, Hooks} ->
+ %% Make sure hooks are there once only.
+ ReadableHooks = [cth_readable_failonly, cth_readable_shell],
+ NewHooks = (Hooks -- ReadableHooks) ++ ReadableHooks,
+ lists:keyreplace(ct_hooks, 1, Opts, {ct_hooks, NewHooks})
+ end.
+
select_tests(State, ProjectApps, CmdOpts, CfgOpts) ->
FixedOpts = lists:filter(fun({_, _}) -> true; (V) -> ?WARN("`~p` is not a valid option for `ct_opts`", [V]) end, CfgOpts),
Merged = lists:ukeymerge(1,
@@ -249,7 +261,7 @@ inject(Opts, State) ->
%% append `ct_compile_opts` to app defined `erl_opts`
ErlOpts = rebar_opts:get(Opts, erl_opts, []),
CTOpts = rebar_state:get(State, ct_compile_opts, []),
- NewErlOpts = CTOpts ++ ErlOpts,
+ NewErlOpts = add_transforms(CTOpts) ++ ErlOpts,
%% append `ct_first_files` to app defined `erl_first_files`
FirstFiles = rebar_opts:get(Opts, erl_first_files, []),
CTFirstFiles = rebar_state:get(State, ct_first_files, []),
@@ -259,6 +271,11 @@ inject(Opts, State) ->
Opts,
[{erl_opts, NewErlOpts}, {erl_first_files, NewFirstFiles}]).
+add_transforms(CTOpts) ->
+ ReadableTransform = [{parse_transform, cth_readable_transform}],
+ (CTOpts -- ReadableTransform) ++ ReadableTransform.
+
+
test_dirs(State, Apps, Opts) ->
case {proplists:get_value(suite, Opts), proplists:get_value(dir, Opts)} of
{Suites, undefined} -> set_compile_dirs(State, Apps, {suite, Suites});