From 2348367cc4148394ba481594dbea009bc914eddc Mon Sep 17 00:00:00 2001 From: Pablo Costas Date: Mon, 3 Aug 2020 18:05:49 +0200 Subject: [PATCH] Fix symlink to last CT logs directory with logdir option present --- src/rebar_prv_common_test.erl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl index 6f4050ae..d2340c1b 100644 --- a/src/rebar_prv_common_test.erl +++ b/src/rebar_prv_common_test.erl @@ -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 -> @@ -122,9 +122,12 @@ format_error({error_reading_testspec, Reason}) -> %% @doc Tries to make the symlink `_build//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