Browse Source

Run a soft purge while within the compiler step

Prevents the killing of a plugin with itself
pull/1686/head
Fred Hebert 7 years ago
parent
commit
d45bacb73b
8 changed files with 92 additions and 3 deletions
  1. +1
    -1
      src/rebar_prv_compile.erl
  2. +5
    -1
      src/rebar_utils.erl
  3. +11
    -1
      systest/all_SUITE.erl
  4. +16
    -0
      systest/all_SUITE_data/grisp_explode/rebar.config
  5. +8
    -0
      systest/all_SUITE_data/grisp_explode/rebar.lock
  6. +17
    -0
      systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src
  7. +15
    -0
      systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl
  8. +19
    -0
      systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl

+ 1
- 1
src/rebar_prv_compile.erl View File

@ -145,7 +145,7 @@ compile(State, Providers, AppInfo) ->
code:add_pathsa(PluginDepsPaths),
AppFileCompileResult = rebar_otp_app:compile(State, AppInfo4),
%% Clean up after ourselves, leave things as they were.
rebar_utils:remove_from_code_path(PluginDepsPaths),
rebar_utils:remove_from_code_path(PluginDepsPaths, soft_purge),
case AppFileCompileResult of
{ok, AppInfo5} ->

+ 5
- 1
src/rebar_utils.erl View File

@ -49,6 +49,7 @@
update_code/1,
update_code/2,
remove_from_code_path/1,
remove_from_code_path/2,
cleanup_code_path/1,
args_to_tasks/1,
expand_env_variable/3,
@ -753,6 +754,9 @@ update_code(Paths, Opts) ->
end, Paths).
remove_from_code_path(Paths) ->
remove_from_code_path(Paths, purge).
remove_from_code_path(Paths, Type) when Type == purge; Type == soft_purge ->
lists:foreach(fun(Path) ->
Name = filename:basename(Path, "/ebin"),
App = list_to_atom(Name),
@ -763,7 +767,7 @@ remove_from_code_path(Paths) ->
ok;
{ok, Modules} ->
application:unload(App),
[begin code:purge(M), code:delete(M) end || M <- Modules]
[begin code:Type(M), code:delete(M) end || M <- Modules]
end,
code:del_path(Path)
end, lists:usort(Paths)).

+ 11
- 1
systest/all_SUITE.erl View File

@ -29,7 +29,7 @@ end_per_testcase(_Name, Config) ->
Config.
all() ->
[noop, resource_plugins, alias_clash].
[noop, resource_plugins, alias_clash, grisp_explode].
%groups() ->
% [{plugins, [shuffle], []},
@ -66,6 +66,16 @@ alias_clash(Config) ->
?assertNotEqual(nomatch,
re:run(Output, "Not adding provider default test from module rebar_prv_alias_test "
"because it already exists from module rebar_prv_alias_test")),
grisp_explode() ->
[{doc, "Don't force purge a plugin that runs the compile job itself"}].
grisp_explode(Config) ->
%% When the purge handling is wrong, the run fails violently.
{error, {_,Output}} = rebar3("grisp deploy -n robot -v 0.1.0", Config),
ct:pal("Rebar3 Output:~n~s",[Output]),
?assertNotEqual(nomatch,
re:run(Output, "No releases exist in the system for robot:0.1.0!")
),
ok.
%%%%%%%%%%%%%%%

+ 16
- 0
systest/all_SUITE_data/grisp_explode/rebar.config View File

@ -0,0 +1,16 @@
{deps, [grisp]}.
{plugins, [{rebar3_grisp, "0.1.0"}]}.
{erl_opts, [debug_info]}.
{grisp, [
{otp_release, "19"},
{deploy, [
{destination, "/path/to/SD-card"}
]}
]}.
{relx, [
{release, {mygrispproject, "0.1.0"}, [mygrispproject]}
]}.

+ 8
- 0
systest/all_SUITE_data/grisp_explode/rebar.lock View File

@ -0,0 +1,8 @@
{"1.1.0",
[{<<"grisp">>,{pkg,<<"grisp">>,<<"0.1.1">>},0},
{<<"mapz">>,{pkg,<<"mapz">>,<<"0.3.0">>},1}]}.
[
{pkg_hash,[
{<<"grisp">>, <<"5A1318E7B1582D7C5B1E446D149A6F93428A380BCFE7D740E57E4F6B6CDB19DD">>},
{<<"mapz">>, <<"438D24746CE5A252101E00B2032EFDF7FC69EB32689D3B805DE5E6DD7F52614F">>}]}
].

+ 17
- 0
systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src View File

@ -0,0 +1,17 @@
{application, mygrispproject, [
{description, "A GRiSP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, {mygrispproject, []}},
{applications, [
kernel,
stdlib,
grisp
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.

+ 15
- 0
systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl View File

@ -0,0 +1,15 @@
% @doc mygrispproject public API.
% @end
-module(mygrispproject).
-behavior(application).
% Callbacks
-export([start/2]).
-export([stop/1]).
%--- Callbacks -----------------------------------------------------------------
start(_Type, _Args) -> mygrispproject_sup:start_link().
stop(_State) -> ok.

+ 19
- 0
systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl View File

@ -0,0 +1,19 @@
% @doc mygrispproject top level supervisor.
% @end
-module(mygrispproject_sup).
-behavior(supervisor).
% API
-export([start_link/0]).
% Callbacks
-export([init/1]).
%--- API -----------------------------------------------------------------------
start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []).
%--- Callbacks -----------------------------------------------------------------
init([]) -> {ok, { {one_for_all, 0, 1}, []} }.

Loading…
Cancel
Save