瀏覽代碼

Add symlink to the `ct_run` of the last commot test run

Implements #1734. In case of not being able to create the
symlink rebar3 warns through `?DEBUG`.
pull/2248/head
Pablo Costas 5 年之前
父節點
當前提交
009e0ca5b3
共有 1 個檔案被更改,包括 19 行新增0 行删除
  1. +19
    -0
      src/rebar_prv_common_test.erl

+ 19
- 0
src/rebar_prv_common_test.erl 查看文件

@ -74,6 +74,7 @@ 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(),
{ok, State};
Error ->
rebar_paths:set_paths([plugins, deps], State),
@ -118,6 +119,24 @@ format_error({error_reading_testspec, Reason}) ->
%% Internal functions
%% ===================================================================
%% @doc Tries to make the symlink `_build_test_logs/last` to the `ct_run` directory
%% of the last common test run.
-spec symlink_to_last_ct_logs() -> ok.
symlink_to_last_ct_logs() ->
LogsFolder = "_build/test/logs/",
{ok, Filenames} = file:list_dir(LogsFolder),
CtRunFolders = lists:filter(fun(S) -> string:find(S, "ct_run") /= nomatch end, Filenames),
NewestFolder = lists:last(lists:sort(CtRunFolders)),
Target = filename:join(LogsFolder, "last"),
Existing = filename:join(LogsFolder, NewestFolder),
case rebar_file_utils:symlink_or_copy(Existing, Target) of
ok ->
ok;
_ ->
?DEBUG("Warning, couldn't make a symlink to ~ts.", [Target])
end.
setup_name(State) ->
{Long, Short, Opts} = rebar_dist_utils:find_options(State),
rebar_dist_utils:either(Long, Short, Opts).

Loading…
取消
儲存