diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-09-24 21:59:30 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-09-24 21:59:30 -0400 |
commit | 0b0c119d3d27a5dcf07fd7b4fc35dbe0d61a35ea (patch) | |
tree | a499f3cd811c1552e75aef5ebd6c1808b90c6674 | |
parent | 762e8da4d383f38b9afe6002067f4fac3ecf90a8 (diff) | |
parent | 3b0584abd63f412e124faa117777c3c9030754db (diff) |
Merge pull request #834 from tsloughter/newly_added
handle newly added deps to config even when lock is empty
-rw-r--r-- | src/rebar_config.erl | 3 | ||||
-rw-r--r-- | test/rebar_deps_SUITE.erl | 34 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/rebar_config.erl b/src/rebar_config.erl index 15797da..61301cb 100644 --- a/src/rebar_config.erl +++ b/src/rebar_config.erl @@ -86,9 +86,6 @@ verify_config_format([Term | _]) -> %% no lockfile merge_locks(Config, []) -> Config; -%% empty lockfile -merge_locks(Config, [[]]) -> - Config; %% lockfile with entries merge_locks(Config, [Locks]) -> ConfigDeps = proplists:get_value(deps, Config, []), diff --git a/test/rebar_deps_SUITE.erl b/test/rebar_deps_SUITE.erl index fd86226..fcc46c3 100644 --- a/test/rebar_deps_SUITE.erl +++ b/test/rebar_deps_SUITE.erl @@ -3,7 +3,7 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). -all() -> [sub_app_deps, newly_added_dep, http_proxy_settings, https_proxy_settings, {group, git}, {group, pkg}]. +all() -> [sub_app_deps, newly_added_dep, newly_added_after_empty_lock, http_proxy_settings, https_proxy_settings, {group, git}, {group, pkg}]. groups() -> [{all, [], [flat, pick_highest_left, pick_highest_right, @@ -29,6 +29,8 @@ init_per_group(_, Config) -> end_per_group(_, Config) -> Config. +init_per_testcase(newly_added_after_empty_lock, Config) -> + rebar_test_utils:init_rebar_state(Config); init_per_testcase(newly_added_dep, Config) -> rebar_test_utils:init_rebar_state(Config); init_per_testcase(sub_app_deps, Config) -> @@ -252,6 +254,36 @@ newly_added_dep(Config) -> Config, RebarConfig3, ["compile"], {ok, [{app, Name}, {dep, "a"}, {dep, "b", "1.0.0"}, {dep, "c", "1.0.0"}]}). +newly_added_after_empty_lock(Config) -> + AppDir = ?config(apps, Config), + Deps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}]), + {SrcDeps, _} = rebar_test_utils:flat_deps(Deps), + mock_git_resource:mock([{deps, SrcDeps}]), + + Name = rebar_test_utils:create_random_name("app_"), + Vsn = rebar_test_utils:create_random_vsn(), + + SubAppsDir = filename:join([AppDir, "apps", Name]), + rebar_test_utils:create_app(SubAppsDir, Name, Vsn, [kernel, stdlib]), + + TopDeps = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [])), + {ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps}])), + rebar_test_utils:run_and_check( + Config, RebarConfig, ["compile"], + {ok, []}), + + %% Add a and c to top level + TopDeps2 = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}])), + {ok, RebarConfig2} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, TopDeps2}])), + LockFile = filename:join(AppDir, "rebar.lock"), + RebarConfig3 = rebar_config:merge_locks(RebarConfig2, + rebar_config:consult_lock_file(LockFile)), + + %% a should now be installed and c should not change + rebar_test_utils:run_and_check( + Config, RebarConfig3, ["compile"], + {ok, [{app, Name}, {dep, "a", "1.0.0"}]}). + http_proxy_settings(_Config) -> %% Load config |