Ver código fonte

Merge pull request #2248 from pablocostass/symlink_to_last_ct_logs

Add symlink to the `ct_run` of the last common test run
pull/2251/head
Fred Hebert 5 anos atrás
committed by GitHub
pai
commit
b3fd2ed705
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: 4AEE18F83AFDEB23
1 arquivos alterados com 22 adições e 0 exclusões
  1. +22
    -0
      src/rebar_prv_common_test.erl

+ 22
- 0
src/rebar_prv_common_test.erl Ver arquivo

@ -74,9 +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),
{ok, State};
Error ->
rebar_paths:set_paths([plugins, deps], State),
symlink_to_last_ct_logs(State),
Error
end;
Error ->
@ -118,6 +120,26 @@ format_error({error_reading_testspec, Reason}) ->
%% Internal functions
%% ===================================================================
%% @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"]),
{ok, Filenames} = file:list_dir(LogDir),
CtRunDirs = lists:filter(fun(S) -> re:run(S, "ct_run", [unicode]) /= nomatch end, Filenames),
NewestDir = lists:last(lists:sort(CtRunDirs)),
Target = filename:join([LogDir, "last"]),
Existing = filename:join([LogDir, NewestDir]),
case rebar_file_utils:symlink_or_copy(Existing, Target) of
ok -> ok;
exists ->
%% in case the symlink already exists we remove it
%% and make a new updated one
rebar_file_utils:rm_rf(Target),
rebar_file_utils:symlink_or_copy(Existing, Target);
Reason -> ?DEBUG("Warning, couldn't make a symlink to ~ts, reason: ~p.", [Target, Reason])
end.
setup_name(State) ->
{Long, Short, Opts} = rebar_dist_utils:find_options(State),
rebar_dist_utils:either(Long, Short, Opts).

Carregando…
Cancelar
Salvar