Skip to content

Commit

Permalink
Merge pull request #2458 from TheGeorge/cth_readable_config
Browse files Browse the repository at this point in the history
fix injection of cth_readable to allow for hook configuration
  • Loading branch information
ferd authored Jan 6, 2021
2 parents 3ef4f08 + c71ffd4 commit 575890f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/rebar_prv_common_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,23 @@ add_hooks(Opts, State) ->
[{ct_hooks, [cth_readable_failonly, readable_shell_type(Other),
cth_retry] ++ FailFast} | Opts];
{Other, {ct_hooks, Hooks}} ->
%% Make sure hooks are there once only.
%% Make sure hooks are there once only and add wanted hooks that are not defined yet
ReadableHooks = [cth_readable_failonly, readable_shell_type(Other),
cth_retry] ++ FailFast,
AllReadableHooks = [cth_readable_failonly, cth_retry, cth_fail_fast,
cth_readable_shell, cth_readable_compact_shell],
NewHooks = (Hooks -- AllReadableHooks) ++ ReadableHooks,
NewHooks = Hooks ++ [ReadableHook ||
ReadableHook <- ReadableHooks,
not is_defined(ReadableHook, Hooks)
],
lists:keyreplace(ct_hooks, 1, Opts, {ct_hooks, NewHooks})
end.

is_defined(_Key, []) -> false;
is_defined(Key, [Key | _Hs]) -> true;
is_defined(Key, [{Key, _Opts} | _Hs]) -> true;
is_defined(Key, [{Key, _Opts, _Prio} | _Hs]) -> true;
is_defined(Key, [_ | Hs]) -> is_defined(Key, Hs).


readable_shell_type(true) -> cth_readable_shell;
readable_shell_type(compact) -> cth_readable_compact_shell.

Expand Down

0 comments on commit 575890f

Please sign in to comment.