瀏覽代碼

Merge pull request #1698 from campanja-forks/run-clean-hooks

fix hooks and plugins usage when cleaning build artifacts for deps
pull/1000/merge
Fred Hebert 7 年之前
committed by GitHub
父節點
當前提交
94ea0630b1
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 3 個文件被更改,包括 34 次插入6 次删除
  1. +8
    -3
      src/rebar_app_discover.erl
  2. +1
    -1
      src/rebar_prv_clean.erl
  3. +25
    -2
      test/rebar_hooks_SUITE.erl

+ 8
- 3
src/rebar_app_discover.erl 查看文件

@ -331,14 +331,19 @@ create_app_info(AppInfo, AppDir, AppFile) ->
AppInfo2 = rebar_app_info:applications(
rebar_app_info:app_details(AppInfo1, AppDetails),
IncludedApplications++Applications),
Valid = case rebar_app_utils:validate_application_info(AppInfo2) =:= true
andalso rebar_app_info:has_all_artifacts(AppInfo2) =:= true of
C = rebar_config:consult(AppDir),
AppInfo3 = rebar_app_info:update_opts(AppInfo2,
rebar_app_info:opts(AppInfo2), C),
?DEBUG("create_app_info(~p, ~p, ~p) -> ~n~p~n",
[AppInfo, AppDir, AppFile, AppInfo3]),
Valid = case rebar_app_utils:validate_application_info(AppInfo3) =:= true
andalso rebar_app_info:has_all_artifacts(AppInfo3) =:= true of
true ->
true;
_ ->
false
end,
rebar_app_info:dir(rebar_app_info:valid(AppInfo2, Valid), AppDir).
rebar_app_info:dir(rebar_app_info:valid(AppInfo3, Valid), AppDir).
%% @doc Read in and parse the .app file if it is availabe. Do the same for
%% the .app.src file if it exists.

+ 1
- 1
src/rebar_prv_clean.erl 查看文件

@ -12,7 +12,7 @@
-include("rebar.hrl").
-define(PROVIDER, clean).
-define(DEPS, [app_discovery]).
-define(DEPS, [app_discovery, install_deps]).
%% ===================================================================
%% Public API

+ 25
- 2
test/rebar_hooks_SUITE.erl 查看文件

@ -12,7 +12,8 @@
run_hooks_once_profiles/1,
run_hooks_for_plugins/1,
eunit_app_hooks/1,
deps_hook_namespace/1]).
deps_hook_namespace/1,
deps_clean_hook_namespace/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@ -36,7 +37,7 @@ end_per_testcase(_, _Config) ->
all() ->
[build_and_clean_app, run_hooks_once, run_hooks_once_profiles,
escriptize_artifacts, run_hooks_for_plugins, deps_hook_namespace,
eunit_app_hooks].
deps_clean_hook_namespace, eunit_app_hooks].
%% Test post provider hook cleans compiled project app, leaving it invalid
build_and_clean_app(Config) ->
@ -134,6 +135,28 @@ deps_hook_namespace(Config) ->
{ok, [{dep, "some_dep"}]}
).
deps_clean_hook_namespace(Config) ->
mock_git_resource:mock([{deps, [{some_dep, "0.0.1"}]}]),
Deps = rebar_test_utils:expand_deps(git, [{"some_dep", "0.0.1", []}]),
TopDeps = rebar_test_utils:top_level_deps(Deps),
RebarConfig = [
{deps, TopDeps},
{overrides, [
{override, some_dep, [
{provider_hooks, [
{pre, [
{compile, clean}
]}
]}
]}
]}
],
rebar_test_utils:run_and_check(
Config, RebarConfig, ["clean"],
{ok, [{dep, "some_dep"}]}
).
%% Checks that a hook that is defined on an app (not a top level hook of a project with subapps) is run
eunit_app_hooks(Config) ->
AppDir = ?config(apps, Config),

Loading…
取消
儲存