Skip to content

Commit

Permalink
Merge pull request #2319 from pablocostass/2318_fix_ct_symlink_with_l…
Browse files Browse the repository at this point in the history
…ogdir

Fix symlink to last CT logs directory with logdir option present
  • Loading branch information
ferd authored Aug 6, 2020
2 parents c17b7b0 + 2348367 commit dab7938
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/rebar_prv_common_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ do(State, Tests) ->
%% Run ct provider post hooks for all project apps and top level project hooks
rebar_hooks:run_project_and_app_hooks(Cwd, post, ?PROVIDER, Providers, State),
rebar_paths:set_paths([plugins, deps], State),
symlink_to_last_ct_logs(State),
symlink_to_last_ct_logs(State, T),
{ok, State};
Error ->
rebar_paths:set_paths([plugins, deps], State),
symlink_to_last_ct_logs(State),
symlink_to_last_ct_logs(State, T),
Error
end;
Error ->
Expand Down Expand Up @@ -122,9 +122,12 @@ format_error({error_reading_testspec, Reason}) ->

%% @doc Tries to make the symlink `_build/<profile>/logs/last` to the `ct_run` directory
%% of the last common test run.
-spec symlink_to_last_ct_logs(rebar_state:t()) -> ok.
symlink_to_last_ct_logs(State) ->
LogDir = filename:join([rebar_dir:base_dir(State), "logs"]),
-spec symlink_to_last_ct_logs(rebar_state:t(), list()) -> ok.
symlink_to_last_ct_logs(State, Opts) ->
LogDir = case proplists:get_value(logdir, Opts) of
undefined -> filename:join([rebar_dir:base_dir(State), "logs"]);
Dir -> Dir
end,
{ok, Filenames} = file:list_dir(LogDir),
CtRunDirs = lists:filter(fun(S) -> re:run(S, "ct_run", [unicode]) /= nomatch end, Filenames),
case CtRunDirs of
Expand Down

0 comments on commit dab7938

Please sign in to comment.