diff options
author | Tristan Sloughter <t@crashfast.com> | 2016-03-02 12:53:54 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2016-03-02 12:54:15 -0600 |
commit | 268713c5d7642bf2911aa6019abe54b776c5993c (patch) | |
tree | 879f35f4d9b2ea53c0bdf28472ecffed1b99bfbb | |
parent | 3a27eb6f433625618713eca0358bf8138548e4a6 (diff) |
include project_plugins in plugins that can be upgraded
-rw-r--r-- | src/rebar_prv_plugins_upgrade.erl | 15 | ||||
-rw-r--r-- | test/rebar_plugins_SUITE.erl | 43 |
2 files changed, 50 insertions, 8 deletions
diff --git a/src/rebar_prv_plugins_upgrade.erl b/src/rebar_prv_plugins_upgrade.erl index 87f20df..03521c7 100644 --- a/src/rebar_prv_plugins_upgrade.erl +++ b/src/rebar_prv_plugins_upgrade.erl @@ -78,13 +78,14 @@ upgrade(Plugin, State) -> find_plugin(Plugin, Profiles, State) -> ec_lists:search(fun(Profile) -> - Plugins = rebar_state:get(State, {plugins, Profile}, []), - case rebar_utils:tup_find(list_to_atom(Plugin), Plugins) of - false -> - not_found; - P -> - {ok, P} - end + Plugins = rebar_state:get(State, {plugins, Profile}, []) ++ + rebar_state:get(State, {project_plugins, Profile}, []), + case rebar_utils:tup_find(list_to_atom(Plugin), Plugins) of + false -> + not_found; + P -> + {ok, P} + end end, Profiles). build_plugin(AppInfo, Apps, State) -> diff --git a/test/rebar_plugins_SUITE.erl b/test/rebar_plugins_SUITE.erl index 355e156..a313683 100644 --- a/test/rebar_plugins_SUITE.erl +++ b/test/rebar_plugins_SUITE.erl @@ -11,6 +11,7 @@ complex_plugins/1, list/1, upgrade/1, + upgrade_project_plugin/1, sub_app_plugins/1, sub_app_plugin_overrides/1, project_plugins/1]). @@ -35,7 +36,8 @@ end_per_testcase(_, _Config) -> catch meck:unload(). all() -> - [compile_plugins, compile_global_plugins, complex_plugins, list, upgrade, sub_app_plugins, sub_app_plugin_overrides, project_plugins]. + [compile_plugins, compile_global_plugins, complex_plugins, list, upgrade, upgrade_project_plugin, + sub_app_plugins, sub_app_plugin_overrides, project_plugins]. %% Tests that compiling a project installs and compiles the plugins of deps compile_plugins(Config) -> @@ -212,6 +214,45 @@ upgrade(Config) -> {ok, [{app, Name}, {plugin, PkgName, <<"0.1.3">>}]} ). +upgrade_project_plugin(Config) -> + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + PkgName = rebar_test_utils:create_random_name("pkg1_"), + mock_git_resource:mock([]), + mock_pkg_resource:mock([ + {pkgdeps, [{{iolist_to_binary(PkgName), <<"0.1.0">>}, []}, + {{iolist_to_binary(PkgName), <<"0.0.1">>}, []}, + {{iolist_to_binary(PkgName), <<"0.1.1">>}, []}]} + ]), + + RConfFile = rebar_test_utils:create_config(AppDir, [{project_plugins, [list_to_atom(PkgName)]}]), + {ok, RConf} = file:consult(RConfFile), + + %% Build with deps. + rebar_test_utils:run_and_check( + Config, RConf, ["compile"], + {ok, [{app, Name}, {plugin, PkgName, <<"0.1.1">>}]} + ), + + catch mock_pkg_resource:unmock(), + mock_pkg_resource:mock([ + {pkgdeps, [{{iolist_to_binary(PkgName), <<"0.1.0">>}, []}, + {{iolist_to_binary(PkgName), <<"0.0.1">>}, []}, + {{iolist_to_binary(PkgName), <<"0.1.3">>}, []}, + {{iolist_to_binary(PkgName), <<"0.1.1">>}, []}]}, + {upgrade, [PkgName]} + ]), + + %% Build with deps. + rebar_test_utils:run_and_check( + Config, RConf, ["plugins", "upgrade", PkgName], + {ok, [{app, Name}, {plugin, PkgName, <<"0.1.3">>}]} + ). + sub_app_plugins(Config) -> AppDir = ?config(apps, Config), |