Skip to content

Commit

Permalink
Add stop_reason_is_not_logged_in_tracked testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Nov 20, 2023
1 parent 39dfdb9 commit e637138
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/cets_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ only_for_logger_cases() ->
logs_are_printed_when_join_fails_because_servers_overlap,
join_done_already_while_waiting_for_lock_so_do_nothing,
atom_error_is_logged_in_tracked,
stop_reason_is_not_logged_in_tracked,
other_reason_is_logged_in_tracked,
nested_calls_errors_are_logged_once_with_tuple_reason,
nested_calls_errors_are_logged_once_with_map_reason
].
Expand Down Expand Up @@ -1024,6 +1026,45 @@ atom_error_is_logged_in_tracked(_Config) ->
] =
receive_all_logs_with_log_ref(?FUNCTION_NAME, LogRef).

stop_reason_is_not_logged_in_tracked(_Config) ->
logger_debug_h:start(#{id => ?FUNCTION_NAME}),
Me = self(),
LogRef = make_ref(),
F = fun() ->
Me ! ready,
timer:sleep(infinity)
end,
Pid = spawn(fun() -> cets_long:run_tracked(#{log_ref => LogRef}, F) end),
receive_message(ready),
exit(Pid, stop),
wait_for_down(Pid),
[] = receive_all_logs_with_log_ref(?FUNCTION_NAME, LogRef).

%% Counter example for stop_reason_is_not_logged_in_tracked
other_reason_is_logged_in_tracked(_Config) ->
logger_debug_h:start(#{id => ?FUNCTION_NAME}),
Me = self(),
LogRef = make_ref(),
F = fun() ->
Me ! ready,
timer:sleep(infinity)
end,
Pid = spawn(fun() -> cets_long:run_tracked(#{log_ref => LogRef}, F) end),
receive_message(ready),
exit(Pid, bad_stuff_happened),
wait_for_down(Pid),
[
#{
level := error,
msg :=
{report, #{
what := task_failed,
log_ref := LogRef,
reason := bad_stuff_happened
}}
}
] = receive_all_logs_with_log_ref(?FUNCTION_NAME, LogRef).

nested_calls_errors_are_logged_once_with_tuple_reason(_Config) ->
logger_debug_h:start(#{id => ?FUNCTION_NAME}),
LogRef = make_ref(),
Expand Down

0 comments on commit e637138

Please sign in to comment.