summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-12-06 11:37:07 -0500
committerGitHub <noreply@github.com>2017-12-06 11:37:07 -0500
commit8b2bca0e64d5f54b97f6315aa5b2c3380ed92c99 (patch)
tree0404d9c817ae3de555f1b1cc757d725af2beaf67
parentdb05d1ead04f5928a0e865d8317ad6204637cc48 (diff)
parentf12871451f2c60bc35da053198ccc48d1b1db687 (diff)
Merge pull request #1686 from ferd/global-plugin-path-fix
Prevent plugin unloading from killing currently running command (soft-purge in-compile)
-rw-r--r--src/rebar_utils.erl8
-rw-r--r--systest/all_SUITE.erl13
-rw-r--r--systest/all_SUITE_data/grisp_explode/rebar.config16
-rw-r--r--systest/all_SUITE_data/grisp_explode/rebar.lock8
-rw-r--r--systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src17
-rw-r--r--systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl15
-rw-r--r--systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl19
7 files changed, 94 insertions, 2 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 5ea0452..b633760 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -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)).
diff --git a/systest/all_SUITE.erl b/systest/all_SUITE.erl
index a0cfd3f..6d2f14f 100644
--- a/systest/all_SUITE.erl
+++ b/systest/all_SUITE.erl
@@ -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 %%%
%%%%%%%%%%%%%%%
diff --git a/systest/all_SUITE_data/grisp_explode/rebar.config b/systest/all_SUITE_data/grisp_explode/rebar.config
new file mode 100644
index 0000000..43c9f63
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/rebar.config
@@ -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]}
+]}.
diff --git a/systest/all_SUITE_data/grisp_explode/rebar.lock b/systest/all_SUITE_data/grisp_explode/rebar.lock
new file mode 100644
index 0000000..2523b13
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/rebar.lock
@@ -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">>}]}
+].
diff --git a/systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src
new file mode 100644
index 0000000..0f0a396
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.app.src
@@ -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, []}
+]}.
diff --git a/systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl
new file mode 100644
index 0000000..a9152fe
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/src/mygrispproject.erl
@@ -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.
diff --git a/systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl b/systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl
new file mode 100644
index 0000000..aef0d4f
--- /dev/null
+++ b/systest/all_SUITE_data/grisp_explode/src/mygrispproject_sup.erl
@@ -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}, []} }.