Skip to content

Commit

Permalink
improving truncated_counter_file reporting at ct_markdown_errors_hook
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysGonchar committed Jul 4, 2023
1 parent 20accae commit 7c27728
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
3 changes: 3 additions & 0 deletions big_tests/failure_repoting_testing.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
%%% and an overall resulting all_groups.summary file.
{ct_hooks, [ct_groups_summary_hook]}.

%%% this hook generates /tmp/ct_summary, /tmp/ct_markdown
%%% and /tmp/ct_markdown_truncated. these files are required
%%% for GH and GA4 CI reporting.
{ct_hooks, [ct_markdown_errors_hook]}.

%%% this hook prints execution summary in the end of
Expand Down
21 changes: 6 additions & 15 deletions big_tests/src/ct_markdown_errors_hook.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,22 @@ handle_return_unsafe(SuiteName, Place, Return, Config, State) ->
exec_limited_number_of_times(F, State)
end.

exec_limited_number_of_times(_F, State=#state{limit=0, file=_File,
truncated_counter_file = TrFile}) ->
exec_limited_number_of_times(F, State=#state{limit=Limit}) when Limit > 0->
F(),
State#state{limit=Limit-1};
exec_limited_number_of_times(_F, State=#state{truncated_counter_file = TrFile,
limit=Limit, file=_File})->
%% Log truncated, increment counter
TrCounter = old_truncated_counter_value(TrFile),
TrCounter = (-1 * Limit),
file:write_file(TrFile, integer_to_binary(TrCounter+1)),
State;
exec_limited_number_of_times(F, State=#state{limit=Limit}) ->
F(),
State#state{limit=Limit-1}.

old_truncated_counter_value(TrFile) ->
case file:read_file(TrFile) of
{ok, Bin} ->
binary_to_integer(Bin);
_ ->
0
end.

log_summary(SuiteName, GroupName, Place, #state{summary_file = SummaryFile}) ->
SummaryText = make_summary_text(SuiteName, GroupName, Place),
file:write_file(SummaryFile, [SummaryText, $\n], [append]),
ok.

log_error(SuiteName, GroupName, Place, Error, Config, #state{file = File, summary_file = _SummaryFile}) ->
_MaybeLogLink = make_log_link(Config),
LogLink = make_log_link(Config),
%% Spoler syntax
%% https://github.com/dear-github/dear-github/issues/166
Expand Down
3 changes: 1 addition & 2 deletions big_tests/src/ct_test_hook.erl
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ start_tracing() ->
{ok, _Pid} ->
dbg:p(all, call),
% dbg:tp(?MODULE, []),
% dbg:tpl(ct_markdown_errors_hook, cx),
dbg:tp(ct_groups_summary_hook, cx),
dbg:tp(ct_markdown_errors_hook, cx),
ok;
{error, already_started} ->
ok
Expand Down
26 changes: 13 additions & 13 deletions big_tests/tests/test_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
-define(ERROR(E), (error(E))).
% -define(ERROR(E), (exit(E))).

all() -> [{group, passing_repeating_group_with_autoskip}].
% [{group, test_group},
% {group, skipped_test_group},
% {group, failing_test_group_1},
% {group, failing_test_group_2},
% {group, nested_test_group},
% {group, deeply_nested_test_group},
% {group, failing_nested_test_group_1},
% {group, failing_nested_test_group_2},
% {group, failing_repeating_group},
% {group, passing_repeating_group},
% {group, passing_repeating_group_with_autoskip}
% | test_cases() ].
all() ->
[{group, test_group},
{group, skipped_test_group},
{group, failing_test_group_1},
{group, failing_test_group_2},
{group, nested_test_group},
{group, deeply_nested_test_group},
{group, failing_nested_test_group_1},
{group, failing_nested_test_group_2},
{group, failing_repeating_group},
{group, passing_repeating_group},
{group, passing_repeating_group_with_autoskip}
| test_cases() ].

groups() ->
[{test_group, [], test_cases()},
Expand Down

0 comments on commit 7c27728

Please sign in to comment.