summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-08-24 07:51:28 +1200
committerFred Hebert <mononcqc@ferd.ca>2015-08-24 07:51:28 +1200
commit807daff78b9d648e42c482033504af880699bd58 (patch)
tree639cc2a71ebe37ed129c79e119ef12d6516b0af3
parent657a1bf52e4de27d3d302de707fdd53fa3d0632e (diff)
parentf2f63013fedbde4ea1de0ae09d767eb92eb1a5d2 (diff)
Merge pull request #745 from tsloughter/override_deps
override 'deps' now automatically overrides '{deps,default}'
-rw-r--r--src/rebar_state.erl13
-rw-r--r--test/rebar_compile_SUITE.erl44
2 files changed, 52 insertions, 5 deletions
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index f365293..6feae81 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -242,7 +242,9 @@ apply_overrides(State=#state_t{overrides=Overrides}, AppName) ->
%% Inefficient. We want the order we get here though.
State1 = lists:foldl(fun({override, O}, StateAcc) ->
- lists:foldl(fun({Key, Value}, StateAcc1) ->
+ lists:foldl(fun({deps, Value}, StateAcc1) ->
+ rebar_state:set(StateAcc1, {deps,default}, Value);
+ ({Key, Value}, StateAcc1) ->
rebar_state:set(StateAcc1, Key, Value)
end, StateAcc, O);
(_, StateAcc) ->
@@ -250,7 +252,9 @@ apply_overrides(State=#state_t{overrides=Overrides}, AppName) ->
end, State, Overrides),
State2 = lists:foldl(fun({override, N, O}, StateAcc) when N =:= Name ->
- lists:foldl(fun({Key, Value}, StateAcc1) ->
+ lists:foldl(fun({deps, Value}, StateAcc1) ->
+ rebar_state:set(StateAcc1, {deps,default}, Value);
+ ({Key, Value}, StateAcc1) ->
rebar_state:set(StateAcc1, Key, Value)
end, StateAcc, O);
(_, StateAcc) ->
@@ -258,7 +262,10 @@ apply_overrides(State=#state_t{overrides=Overrides}, AppName) ->
end, State1, Overrides),
State3 = lists:foldl(fun({add, N, O}, StateAcc) when N =:= Name ->
- lists:foldl(fun({Key, Value}, StateAcc1) ->
+ lists:foldl(fun({deps, Value}, StateAcc1) ->
+ OldValue = rebar_state:get(StateAcc1, {deps,default}, []),
+ rebar_state:set(StateAcc1, {deps,default}, Value++OldValue);
+ ({Key, Value}, StateAcc1) ->
OldValue = rebar_state:get(StateAcc1, Key, []),
rebar_state:set(StateAcc1, Key, Value++OldValue)
end, StateAcc, O);
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl
index 1d5aab8..f726943 100644
--- a/test/rebar_compile_SUITE.erl
+++ b/test/rebar_compile_SUITE.erl
@@ -23,7 +23,9 @@
erl_first_files_test/1,
mib_test/1,
only_default_transitive_deps/1,
- clean_all/1]).
+ clean_all/1,
+ override_deps/1,
+ profile_override_deps/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -52,7 +54,7 @@ all() ->
dont_recompile_yrl_or_xrl, delete_beam_if_source_deleted,
deps_in_path, checkout_priority, highest_version_of_pkg_dep,
parse_transform_test, erl_first_files_test, mib_test, only_default_transitive_deps,
- clean_all].
+ clean_all, override_deps, profile_override_deps].
build_basic_app(Config) ->
AppDir = ?config(apps, Config),
@@ -591,3 +593,41 @@ clean_all(Config) ->
Config, RConf, ["clean", "--all"],
{ok, [{app, Name, invalid}, {app, DepName, invalid}, {app, PkgName, invalid}]}
).
+
+override_deps(Config) ->
+ mock_git_resource:mock([{deps, [{some_dep, "0.0.1"},{other_dep, "0.0.1"}]}]),
+ Deps = rebar_test_utils:expand_deps(git, [{"some_dep", "0.0.1", [{"other_dep", "0.0.1", []}]}]),
+ TopDeps = rebar_test_utils:top_level_deps(Deps),
+
+ RebarConfig = [
+ {deps, TopDeps},
+ {overrides, [
+ {override, some_dep, [
+ {deps, []}
+ ]}
+ ]}
+ ],
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["compile"],
+ {ok, [{dep, "some_dep"},{dep_not_exist, "other_dep"}]}
+ ).
+
+profile_override_deps(Config) ->
+ mock_git_resource:mock([{deps, [{some_dep, "0.0.1"},{other_dep, "0.0.1"}]}]),
+ Deps = rebar_test_utils:expand_deps(git, [{"some_dep", "0.0.1", [{"other_dep", "0.0.1", []}]}]),
+ TopDeps = rebar_test_utils:top_level_deps(Deps),
+
+ RebarConfig = [
+ {deps, TopDeps},
+ {profiles, [{a,
+ [{overrides, [
+ {override, some_dep, [
+ {deps, []}
+ ]}
+ ]}
+ ]}
+ ]}],
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["as", "a", "compile"],
+ {ok, [{dep, "some_dep"},{dep_not_exist, "other_dep"}]}
+ ).