Skip to content

Commit

Permalink
Merge pull request #2321 from pablocostass/fix_keep_logs_pattern_match
Browse files Browse the repository at this point in the history
Add extra pattern matching clause to not crash handling with keep_logs
  • Loading branch information
ferd authored Aug 7, 2020
2 parents dab7938 + 01a1ce8 commit a5bfc23
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rebar_prv_common_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,16 @@ handle_keep_logs(LogDir, N) ->
case Dirs of
%% first time running the tests, there are no logs to delete
[] -> ok;
_ ->
%% during the next run we would crash because of keep_logs
_ when length(Dirs) >= N ->
SortedDirs = lists:reverse(lists:sort(Dirs)),
%% sort the log dirs and keep the N - 1 newest
{_Keep, Discard} = lists:split(N - 1, SortedDirs),
?DEBUG("Removing the following directories because keep_logs option was found: ~p", [Discard]),
[rebar_file_utils:rm_rf(filename:join([LogDir, Dir])) || Dir <- Discard],
ok
ok;
%% we still dont have enough log run directories as to crash
_ -> ok
end;
_ -> ok
end.
Expand Down

0 comments on commit a5bfc23

Please sign in to comment.