summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralisdair sullivan <alisdair.sullivan@askuity.com>2015-11-01 13:41:46 -0800
committeralisdair sullivan <alisdair.sullivan@askuity.com>2015-11-01 13:49:47 -0800
commit67bf54d04d332bbff961ab4e8ab730858bcdce7a (patch)
treeda85f23627345dc88eda0f825c34f5ba0cbeeab8 /src
parente72e46fc9d23d8467cd58d1728175ae59d2a7c44 (diff)
add an option to soft purge rather than purge old code
at the cost of some SASL warnings this prevents rebar3 from terminating processes when reloading their code before running tests
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_common_test.erl2
-rw-r--r--src/rebar_prv_eunit.erl2
-rw-r--r--src/rebar_utils.erl18
3 files changed, 12 insertions, 10 deletions
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index 1f4c02d..32d4433 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -38,7 +38,7 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
?INFO("Running Common Test suites...", []),
- rebar_utils:update_code(rebar_state:code_paths(State, all_deps)),
+ rebar_utils:update_code(rebar_state:code_paths(State, all_deps), [soft_purge]),
%% Run ct provider prehooks
Providers = rebar_state:providers(State),
diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl
index 0cdc20b..d5612e8 100644
--- a/src/rebar_prv_eunit.erl
+++ b/src/rebar_prv_eunit.erl
@@ -49,7 +49,7 @@ do(State) ->
do(State, Tests) ->
?INFO("Performing EUnit tests...", []),
- rebar_utils:update_code(rebar_state:code_paths(State, all_deps)),
+ rebar_utils:update_code(rebar_state:code_paths(State, all_deps), [soft_purge]),
%% Run eunit provider prehooks
Providers = rebar_state:providers(State),
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index d00a46f..ea60e42 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -47,6 +47,7 @@
deprecated/4,
indent/1,
update_code/1,
+ update_code/2,
remove_from_code_path/1,
cleanup_code_path/1,
args_to_tasks/1,
@@ -644,7 +645,9 @@ indent(Amount) when erlang:is_integer(Amount) ->
%% Replace code paths with new paths for existing apps and
%% purge code of the old modules from those apps.
-update_code(Paths) ->
+update_code(Paths) -> update_code(Paths, []).
+
+update_code(Paths, Opts) ->
lists:foreach(fun(Path) ->
Name = filename:basename(Path, "/ebin"),
App = list_to_atom(Name),
@@ -654,19 +657,18 @@ update_code(Paths) ->
code:add_patha(Path),
ok;
{ok, Modules} ->
- %% stick rebar ebin dir before purging to prevent
- %% inadvertent termination
- RebarBin = code:lib_dir(rebar, ebin),
- ok = code:stick_dir(RebarBin),
%% replace_path causes problems when running
%% tests in projects like erlware_commons that rebar3
%% also includes
%code:replace_path(App, Path),
code:del_path(App),
code:add_patha(Path),
- [begin code:purge(M), code:delete(M) end || M <- Modules],
- %% unstick rebar dir
- ok = code:unstick_dir(RebarBin)
+ case lists:member(soft_purge, Opts) of
+ true ->
+ [begin code:soft_purge(M), code:delete(M) end || M <- Modules];
+ false ->
+ [begin code:purge(M), code:delete(M) end || M <- Modules]
+ end
end
end, Paths).