summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2018-05-05 10:39:25 -0400
committerFred Hebert <mononcqc@ferd.ca>2018-05-05 10:39:25 -0400
commit254bb7be7c91aed2799061094c571b041038b5fb (patch)
treeb1a5e4f07bdea61eed6ee618ca9b59c5b96fc2d4
parentd457f2af6be3ff75fbe2de32127ce3958bca2c4f (diff)
Logger support in cth_readable; compact CT output
cth_readable 1.4.0 supports the new logger interface from OTP-21, which likely breaks compatibility with R16 builds. It also includes a new compact interface, displaying output such as: ===> Running Common Test suites... %%% rebar_alias_SUITE: ...... %%% rebar_as_SUITE: ........... %%% rebar_compile_SUITE:................................ ............................ %%% rebar_compile_SUITE ==> test_name: SKIPPED %%% rebar_compile_SUITE ==> {tc_user_skip,"compile:env_compiler_options/0 available"} .. %%% rebar_cover_SUITE: ............. %%% rebar_ct_SUITE: .................................... Allowing to display more tests within less screen space. This mode has been added to the ct_readable option under the name 'compact' (now supporting true | false | compact), and has been made default for rebar3.
-rw-r--r--rebar.config2
-rw-r--r--rebar.lock4
-rw-r--r--src/rebar_prv_common_test.erl34
3 files changed, 23 insertions, 17 deletions
diff --git a/rebar.config b/rebar.config
index 4bd205b..d0b2e44 100644
--- a/rebar.config
+++ b/rebar.config
@@ -9,7 +9,7 @@
{bbmustache, "1.3.0"},
{relx, "3.24.4"},
{cf, "0.2.2"},
- {cth_readable, "1.3.4"},
+ {cth_readable, "1.4.0"},
{eunit_formatters, "0.5.0"}]}.
{post_hooks, [{"(linux|darwin|solaris|freebsd|netbsd|openbsd)",
diff --git a/rebar.lock b/rebar.lock
index 9f8f602..8625b5a 100644
--- a/rebar.lock
+++ b/rebar.lock
@@ -2,7 +2,7 @@
[{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.3.0">>},0},
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.0.0">>},0},
{<<"cf">>,{pkg,<<"cf">>,<<"0.2.2">>},0},
- {<<"cth_readable">>,{pkg,<<"cth_readable">>,<<"1.3.4">>},0},
+ {<<"cth_readable">>,{pkg,<<"cth_readable">>,<<"1.4.0">>},0},
{<<"erlware_commons">>,{pkg,<<"erlware_commons">>,<<"1.1.0">>},0},
{<<"eunit_formatters">>,{pkg,<<"eunit_formatters">>,<<"0.5.0">>},0},
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0},
@@ -14,7 +14,7 @@
{<<"bbmustache">>, <<"2010ADAE78830992A4C69680115ECD7D475DD03A72C076BBADDCCBF2D4B32035">>},
{<<"certifi">>, <<"A0C0E475107135F76B8C1D5BC7EFB33CD3815CB3CF3DEA7AEFDD174DABEAD064">>},
{<<"cf">>, <<"7F2913FFF90ABCABD0F489896CFEB0B0674F6C8DF6C10B17A83175448029896C">>},
- {<<"cth_readable">>, <<"CB85DF77CEB7F05854AE241300DB36A72C371740EDD883D8BF75B5F652B7067D">>},
+ {<<"cth_readable">>, <<"F51362E3D365B14DE5AED7E98166E0643F38D004AF9750369D8F90E9F470FCC7">>},
{<<"erlware_commons">>, <<"F69F3D96044C2A9E735CCD76F469FEC5FC851797E5FE23115698B4EDC072191B">>},
{<<"eunit_formatters">>, <<"6A9133943D36A465D804C1C5B6E6839030434B8879C5600D7DDB5B3BAD4CCB59">>},
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>},
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index f800610..9e71ee7 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -227,15 +227,20 @@ add_hooks(Opts, State) ->
case {readable(State), lists:keyfind(ct_hooks, 1, Opts)} of
{false, _} ->
Opts;
- {true, false} ->
- [{ct_hooks, [cth_readable_failonly, cth_readable_shell, cth_retry]} | Opts];
- {true, {ct_hooks, Hooks}} ->
+ {Other, false} ->
+ [{ct_hooks, [cth_readable_failonly, readable_shell_type(Other), cth_retry]} | Opts];
+ {Other, {ct_hooks, Hooks}} ->
%% Make sure hooks are there once only.
- ReadableHooks = [cth_readable_failonly, cth_readable_shell, cth_retry],
- NewHooks = (Hooks -- ReadableHooks) ++ ReadableHooks,
+ ReadableHooks = [cth_readable_failonly, readable_shell_type(Other), cth_retry],
+ AllReadableHooks = [cth_readable_failonly, cth_retry,
+ cth_readable_shell, cth_readable_compact_shell],
+ NewHooks = (Hooks -- AllReadableHooks) ++ ReadableHooks,
lists:keyreplace(ct_hooks, 1, Opts, {ct_hooks, NewHooks})
end.
+readable_shell_type(true) -> cth_readable_shell;
+readable_shell_type(compact) -> cth_readable_compact_shell.
+
select_tests(_, _, _, {error, _} = Error) -> Error;
select_tests(State, ProjectApps, CmdOpts, CfgOpts) ->
%% set application env if sys_config argument is provided
@@ -425,20 +430,21 @@ append(A, B) -> A ++ B.
add_transforms(CTOpts, State) when is_list(CTOpts) ->
case readable(State) of
- true ->
- ReadableTransform = [{parse_transform, cth_readable_transform}],
- (CTOpts -- ReadableTransform) ++ ReadableTransform;
false ->
- CTOpts
+ CTOpts;
+ Other when Other == true; Other == compact ->
+ ReadableTransform = [{parse_transform, cth_readable_transform}],
+ (CTOpts -- ReadableTransform) ++ ReadableTransform
end;
add_transforms({error, _} = Error, _State) -> Error.
readable(State) ->
{RawOpts, _} = rebar_state:command_parsed_args(State),
case proplists:get_value(readable, RawOpts) of
- true -> true;
- false -> false;
- undefined -> rebar_state:get(State, ct_readable, true)
+ "true" -> true;
+ "false" -> false;
+ "compact" -> compact;
+ undefined -> rebar_state:get(State, ct_readable, compact)
end.
test_dirs(State, Apps, Opts) ->
@@ -762,7 +768,7 @@ ct_opts(_State) ->
{scale_timetraps, undefined, "scale_timetraps", boolean, help(scale_timetraps)},
{create_priv_dir, undefined, "create_priv_dir", string, help(create_priv_dir)},
{include, undefined, "include", string, help(include)},
- {readable, undefined, "readable", boolean, help(readable)},
+ {readable, undefined, "readable", string, help(readable)},
{verbose, $v, "verbose", boolean, help(verbose)},
{name, undefined, "name", atom, help(name)},
{sname, undefined, "sname", atom, help(sname)},
@@ -831,7 +837,7 @@ help(create_priv_dir) ->
help(include) ->
"Directories containing additional include files";
help(readable) ->
- "Shows test case names and only displays logs to shell on failures";
+ "Shows test case names and only displays logs to shell on failures (true | compact | false)";
help(verbose) ->
"Verbose output";
help(name) ->