Browse Source

Merge pull request #1686 from ferd/global-plugin-path-fix

Prevent plugin unloading from killing currently running command (soft-purge in-compile)
pull/1688/head
Fred Hebert 7 years ago
committed by GitHub
parent
commit
8b2bca0e64
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 94 additions and 2 deletions
  1. +7
    -1
      src/rebar_utils.erl
  2. +12
    -1
      systest/all_SUITE.erl
  3. +16
    -0
      systest/all_SUITE_data/grisp_explode/rebar.config
  4. +8
    -0
      systest/all_SUITE_data/grisp_explode/rebar.lock
  5. +17
    -0
      systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src
  6. +15
    -0
      systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl
  7. +19
    -0
      systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl

+ 7
- 1
src/rebar_utils.erl View File

@ -763,7 +763,13 @@ remove_from_code_path(Paths) ->
ok;
{ok, Modules} ->
application:unload(App),
[begin code:purge(M), code:delete(M) end || M <- Modules]
[case erlang:check_process_code(self(), M) of
false ->
code:purge(M), code:delete(M);
_ ->
?DEBUG("~p can't purge ~p safely, doing a soft purge", [self(), M]),
code:soft_purge(M) andalso code:delete(M)
end || M <- Modules]
end,
code:del_path(Path)
end, lists:usort(Paths)).

+ 12
- 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], []},
@ -68,6 +68,17 @@ alias_clash(Config) ->
"because it already exists from module rebar_prv_alias_test")),
ok.
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.
%%%%%%%%%%%%%%%
%%% Helpers %%%
%%%%%%%%%%%%%%%

+ 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