diff options
-rw-r--r-- | src/rebar_prv_install_deps.erl | 23 | ||||
-rw-r--r-- | test/rebar_install_deps_SUITE.erl | 14 |
2 files changed, 29 insertions, 8 deletions
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 1884a9c..3612303 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -395,14 +395,8 @@ maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) -> false -> case fetch_app(AppInfo, AppDir, State) of true -> - case needs_symlinking(State, Profile) of - true -> - SymDir = filename:join([rebar_dir:deps_dir(State), rebar_app_info:name(AppInfo)]), - symlink_dep(AppDir, SymDir), - {true, AppInfo}; - false -> - {true, AppInfo} - end; + maybe_symlink_default(State, Profile, AppDir, AppInfo), + {true, AppInfo}; Other -> {Other, AppInfo} end; @@ -417,6 +411,7 @@ maybe_fetch(AppInfo, Profile, Upgrade, Seen, State) -> %% Preserve the state we created with overrides AppState = rebar_app_info:state(AppInfo), AppInfo2 = rebar_app_info:state(AppInfo1, AppState), + maybe_symlink_default(State, Profile, AppDir, AppInfo2), case sets:is_element(rebar_app_info:name(AppInfo), Seen) of true -> {false, AppInfo2}; @@ -445,6 +440,18 @@ needs_symlinking(State, Profile) -> false end. +maybe_symlink_default(State, Profile, AppDir, AppInfo) -> + case needs_symlinking(State, Profile) of + true -> + SymDir = filename:join([rebar_dir:deps_dir(State), + rebar_app_info:name(AppInfo)]), + symlink_dep(AppDir, SymDir), + true; + false -> + false + end. + + symlink_dep(From, To) -> ?INFO("Linking ~s to ~s", [From, To]), filelib:ensure_dir(To), diff --git a/test/rebar_install_deps_SUITE.erl b/test/rebar_install_deps_SUITE.erl index 68fb9dd..d1a1118 100644 --- a/test/rebar_install_deps_SUITE.erl +++ b/test/rebar_install_deps_SUITE.erl @@ -218,6 +218,13 @@ default_profile(Config) -> || {dep, App} <- Apps], [?assertMatch({ok, #file_info{type=directory}}, % somehow symlinks return dirs file:read_file_info(filename:join([BuildDir, "profile", "lib", App]))) + || {dep, App} <- Apps], + %% A second run to another profile also links default to the right spot + rebar_test_utils:run_and_check( + Config, RebarConfig, ["as", "other", "install_deps"], Expect + ), + [?assertMatch({ok, #file_info{type=directory}}, % somehow symlinks return dirs + file:read_file_info(filename:join([BuildDir, "other", "lib", App]))) || {dep, App} <- Apps]. nondefault_profile(Config) -> @@ -234,6 +241,13 @@ nondefault_profile(Config) -> || {dep, App} <- Apps], [?assertMatch({ok, #file_info{type=directory}}, file:read_file_info(filename:join([BuildDir, "nondef", "lib", App]))) + || {dep, App} <- Apps], + %% A second run to another profile doesn't link dependencies + rebar_test_utils:run_and_check( + Config, RebarConfig, ["as", "other", "install_deps"], Expect + ), + [?assertMatch({error, enoent}, + file:read_file_info(filename:join([BuildDir, "default", "lib", App]))) || {dep, App} <- Apps]. |