浏览代码

Merge pull request #1681 from ferd/fix-plugin-paths-again

Fix Plugin path handling (again!)
pull/1669/merge
Fred Hebert 7 年前
提交者 GitHub
父节点
当前提交
2a349a7446
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 4 个文件被更改,包括 107 次插入3 次删除
  1. +4
    -0
      rebar.config
  2. +5
    -3
      src/rebar_plugins.erl
  3. +75
    -0
      systest/all_SUITE.erl
  4. +23
    -0
      systest/all_SUITE_data/resource_plugins/rebar.config

+ 4
- 0
rebar.config 查看文件

@ -43,6 +43,10 @@
{erl_opts, [debug_info, nowarn_export_all]}
]
},
{systest, [
{erl_opts, [debug_info, nowarn_export_all]},
{ct_opts, [{dir, "systest"}]}
]},
{bootstrap, []},

+ 5
- 3
src/rebar_plugins.erl 查看文件

@ -96,8 +96,8 @@ handle_plugin(Profile, Plugin, State, Upgrade) ->
ToBuild = rebar_prv_install_deps:cull_compile(Sorted, []),
%% Add already built plugin deps to the code path
CodePaths = [rebar_app_info:ebin_dir(A) || A <- Apps -- ToBuild],
code:add_pathsa(CodePaths),
PreBuiltPaths = [rebar_app_info:ebin_dir(A) || A <- Apps] -- ToBuild,
code:add_pathsa(PreBuiltPaths),
%% Build plugin and its deps
[build_plugin(AppInfo, Apps, State2) || AppInfo <- ToBuild],
@ -105,10 +105,12 @@ 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],
AllPluginEbins = filelib:wildcard(filename:join([rebar_dir:plugins_dir(State), "*", "ebin"])),
CodePaths = PreBuiltPaths++(AllPluginEbins--ToBuild),
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),
State4 = rebar_state:update_code_paths(State3, all_plugin_deps, PreBuiltPaths++NewCodePaths),
{plugin_providers(Plugin), State4}
catch

+ 75
- 0
systest/all_SUITE.erl 查看文件

@ -0,0 +1,75 @@
-module(all_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-compile([export_all, nowarn_export_all]).
init_per_suite(Config) ->
%% TODO: figure out how to use a local rebar3 copy?
%% Ensure global rebar3 has the same version as current one!
{ok, Vsn} = application:get_key(rebar, vsn),
{ok, ExecVsn} = rebar3("version", [{path, "."} | Config]),
case rebar_string:lexemes(ExecVsn, " ") of
["rebar", Vsn | _] ->
%% Copy all base cases to priv_dir
rebar_file_utils:cp_r([?config(data_dir, Config)],
?config(priv_dir, Config)),
Config;
_ ->
{skip, "expected current version "++Vsn++" in path "
"and found '"++ ExecVsn ++ "'"}
end.
end_per_suite(Config) ->
Config.
init_per_testcase(Name, Config) ->
set_name_config(Name, Config).
end_per_testcase(_Name, Config) ->
Config.
all() ->
[noop, resource_plugins].
%groups() ->
% [{plugins, [shuffle], []},
% {deps, [shuffle], []}].
%%%%%%%%%%%%%%%%%%
%%% TEST CASES %%%
%%%%%%%%%%%%%%%%%%
noop() ->
[{doc, "just a sanity check on the handling of the test suite init/end"}].
noop(_Config) ->
true.
resource_plugins() ->
[{doc, "Issue #1673: "
"Ensure that deps using resource plugins with semver compile."}].
resource_plugins(Config) ->
%% When the environment handling is wrong, the run fails violently.
{ok, Output} = rebar3("compile", Config),
ct:pal("Rebar3 Output:~n~s",[Output]),
ok.
%%%%%%%%%%%%%%%
%%% Helpers %%%
%%%%%%%%%%%%%%%
set_name_config(Atom, Config) ->
[{path,
filename:join([?config(priv_dir, Config),
atom_to_list(?MODULE)++"_data", atom_to_list(Atom)])}
| Config].
rebar3(Args, Config) ->
Exec = case os:type() of
{win32, _} ->
"rebar3.cmd";
_ ->
"rebar3"
end,
Cmd = Exec ++ " " ++ Args,
Opts = [{cd, ?config(path, Config)}, return_on_error, use_stdout],
ct:pal("Calling rebar3 ~s with options ~p", [Cmd, Opts]),
rebar_utils:sh(Cmd, Opts).

+ 23
- 0
systest/all_SUITE_data/resource_plugins/rebar.config 查看文件

@ -0,0 +1,23 @@
%% Sample provided by @tothlac
{plugins, [
{rebar_tidy_deps, ".*", {git, "https://github.com/ferd/rebar3-tidy-deps-plugin.git"}},
{rebar_alias, {git, "https://github.com/tsloughter/rebar_alias.git"}},
rebar3_appup_plugin
]}.
{deps, [
{hackney, {git, "https://github.com/benoitc/hackney.git", {tag, "1.10.1"}}}
]}.
%% Make work despite compat issues with strings and warnings
{overrides, [
{override, rebar3_appup_plugin, [
{erl_opts, [
{platform_define, "^19", brutal_purge_fixed},
{platform_define, "^2", brutal_purge_fixed},
%% warnings_as_errors,
debug_info
]}
]}
]}.

正在加载...
取消
保存