summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-12-03 13:52:51 -0500
committerGitHub <noreply@github.com>2017-12-03 13:52:51 -0500
commitf81f144f38f51efd9ab2d312b1a61dc464fd4738 (patch)
tree71a4008d84b0b42379cd120456ae0eb1a2acc6e3
parent6492020c4f3fa69611e5035bdf09a0a6f0e6615b (diff)
parent6e672852a72f51d088e16f3662b0299744435127 (diff)
Merge pull request #1678 from tsloughter/fix-plugin-path
fix code path when validating plugins
-rw-r--r--src/rebar_plugins.erl2
-rw-r--r--test/rebar_plugins_SUITE.erl28
-rw-r--r--test/rebar_test_utils.erl9
3 files changed, 32 insertions, 7 deletions
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
index 68ba6da..1fc01ff 100644
--- a/src/rebar_plugins.erl
+++ b/src/rebar_plugins.erl
@@ -105,7 +105,7 @@ handle_plugin(Profile, Plugin, State, Upgrade) ->
%% Add newly built deps and plugin to code path
State3 = rebar_state:update_all_plugin_deps(State2, Apps),
NewCodePaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
- code:add_pathsa(CodePaths),
+ code:add_pathsa(NewCodePaths++CodePaths),
%% Store plugin code paths so we can remove them when compiling project apps
State4 = rebar_state:update_code_paths(State3, all_plugin_deps, CodePaths++NewCodePaths),
diff --git a/test/rebar_plugins_SUITE.erl b/test/rebar_plugins_SUITE.erl
index a313683..2d74539 100644
--- a/test/rebar_plugins_SUITE.erl
+++ b/test/rebar_plugins_SUITE.erl
@@ -14,7 +14,8 @@
upgrade_project_plugin/1,
sub_app_plugins/1,
sub_app_plugin_overrides/1,
- project_plugins/1]).
+ project_plugins/1,
+ use_checkout_plugins/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -37,7 +38,7 @@ end_per_testcase(_, _Config) ->
all() ->
[compile_plugins, compile_global_plugins, complex_plugins, list, upgrade, upgrade_project_plugin,
- sub_app_plugins, sub_app_plugin_overrides, project_plugins].
+ sub_app_plugins, sub_app_plugin_overrides, project_plugins, use_checkout_plugins].
%% Tests that compiling a project installs and compiles the plugins of deps
compile_plugins(Config) ->
@@ -370,3 +371,26 @@ project_plugins(Config) ->
?assertEqual(length(Release), 2),
?assertEqual(length(Compile), 1).
+
+use_checkout_plugins(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]),
+
+ PluginName = "checkedout",
+ CheckoutsDir = filename:join(AppDir, "_checkouts/checkedout"),
+ rebar_test_utils:create_plugin(CheckoutsDir, PluginName, "1.0.0", []),
+
+ RConfFile =
+ rebar_test_utils:create_config(AppDir,
+ [{deps, []},
+ {plugins, [list_to_atom(PluginName)]}]),
+ {ok, RConf} = file:consult(RConfFile),
+
+ %% Verify we can run the plugin
+ ?assertMatch({ok, _}, rebar_test_utils:run_and_check(
+ Config, RConf, ["checkedout"],
+ {ok, []}
+ )).
diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl
index c1e8b62..b74aa2f 100644
--- a/test/rebar_test_utils.erl
+++ b/test/rebar_test_utils.erl
@@ -425,15 +425,16 @@ erl_src_file(Name) ->
plugin_src_file(Name) ->
io_lib:format("-module('~s').\n"
- "-export([init/1]).\n"
+ "-export([init/1, do/1]).\n"
"init(State) -> \n"
"Provider = providers:create([\n"
"{name, '~s'},\n"
"{module, '~s'}\n"
"]),\n"
- "{ok, rebar_state:add_provider(State, Provider)}.\n", [filename:basename(Name, ".erl"),
- filename:basename(Name, ".erl"),
- filename:basename(Name, ".erl")]).
+ "{ok, rebar_state:add_provider(State, Provider)}.\n"
+ "do(State) -> {ok, State}.\n", [filename:basename(Name, ".erl"),
+ filename:basename(Name, ".erl"),
+ filename:basename(Name, ".erl")]).
erl_eunitized_src_file(Name) ->
io_lib:format("-module('~s').\n"