Browse Source

fix tracking of all profiles dep paths

pull/358/head
Tristan Sloughter 10 years ago
parent
commit
16e9b3ffa2
5 changed files with 53 additions and 9 deletions
  1. +1
    -2
      bootstrap
  2. +0
    -1
      src/rebar_prv_common_test.erl
  3. +2
    -2
      src/rebar_prv_install_deps.erl
  4. +13
    -2
      src/rebar_state.erl
  5. +37
    -2
      test/rebar_profiles_SUITE.erl

+ 1
- 2
bootstrap View File

@ -90,8 +90,7 @@ compile(App, FirstFiles) ->
bootstrap_rebar3() ->
filelib:ensure_dir("_build/default/lib/rebar/ebin/dummy.beam"),
filelib:ensure_dir("_build/default/lib/rebar/src/dummy.erl"),
ec_file:copy("src", "_build/default/lib/rebar/src", [recursive]),
file:make_symlink(filename:absname("src"), filename:absname("_build/default/lib/rebar/src")),
Sources = filelib:wildcard("src/*.erl"),
[compile:file(X, [{outdir, "_build/default/lib/rebar/ebin/"}]) || X <- Sources],
code:add_path(filename:absname("_build/default/lib/rebar/ebin")).

+ 0
- 1
src/rebar_prv_common_test.erl View File

@ -38,7 +38,6 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
?INFO("Running Common Test suites...", []),
code:add_pathsa(rebar_state:code_paths(State, all_deps)),
%% Run ct provider prehooks

+ 2
- 2
src/rebar_prv_install_deps.erl View File

@ -151,9 +151,9 @@ handle_deps(Profile, State0, Deps, Upgrade, Locks) ->
,lists:ukeysort(2, SrcApps)
,lists:ukeysort(2, Solved)),
State3 = rebar_state:all_deps(State2, AllDeps),
State3 = rebar_state:update_all_deps(State2, AllDeps),
CodePaths = [rebar_app_info:ebin_dir(A) || A <- AllDeps],
State4 = rebar_state:code_paths(State3, all_deps, CodePaths),
State4 = rebar_state:update_code_paths(State3, all_deps, CodePaths),
{ok, AllDeps, State4}.

+ 13
- 2
src/rebar_state.erl View File

@ -3,7 +3,7 @@
-export([new/0, new/1, new/2, new/3,
get/2, get/3, set/3,
code_paths/2, code_paths/3,
code_paths/2, code_paths/3, update_code_paths/3,
opts/1, opts/2,
default/1, default/2,
@ -24,7 +24,7 @@
project_apps/1, project_apps/2,
deps_to_build/1, deps_to_build/2,
all_deps/1, all_deps/2,
all_deps/1, all_deps/2, update_all_deps/2,
namespace/1, namespace/2,
deps_names/1,
@ -146,6 +146,14 @@ code_paths(#state_t{code_paths=CodePaths}, Key) ->
code_paths(State=#state_t{code_paths=CodePaths}, Key, CodePath) ->
State#state_t{code_paths=dict:store(Key, CodePath, CodePaths)}.
update_code_paths(State=#state_t{code_paths=CodePaths}, Key, CodePath) ->
case dict:is_key(Key, CodePaths) of
true ->
State#state_t{code_paths=dict:append_list(Key, CodePath, CodePaths)};
false ->
State#state_t{code_paths=dict:store(Key, CodePath, CodePaths)}
end.
opts(#state_t{opts=Opts}) ->
Opts.
@ -312,6 +320,9 @@ all_deps(#state_t{all_deps=Apps}) ->
all_deps(State=#state_t{}, NewApps) ->
State#state_t{all_deps=NewApps}.
update_all_deps(State=#state_t{all_deps=Apps}, NewApps) ->
State#state_t{all_deps=Apps++NewApps}.
namespace(#state_t{namespace=Namespace}) ->
Namespace.

+ 37
- 2
test/rebar_profiles_SUITE.erl View File

@ -7,6 +7,7 @@
all/0,
profile_new_key/1,
profile_merge_keys/1,
all_deps_code_paths/1,
profile_merges/1,
add_to_profile/1,
add_to_existing_profile/1,
@ -21,7 +22,7 @@
-include_lib("kernel/include/file.hrl").
all() ->
[profile_new_key, profile_merge_keys, profile_merges,
[profile_new_key, profile_merge_keys, all_deps_code_paths, profile_merges,
add_to_profile, add_to_existing_profile,
profiles_remain_applied_with_config_present,
test_profile_applied_at_completion,
@ -95,6 +96,40 @@ profile_merge_keys(Config) ->
,{dep, "a", "1.0.0"}
,{dep, "b", "2.0.0"}]}).
all_deps_code_paths(Config) ->
AppDir = ?config(apps, Config),
AllDeps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
,{"b", "2.0.0", []}]),
mock_git_resource:mock([{deps, rebar_test_utils:flat_deps(AllDeps)}]),
Name = rebar_test_utils:create_random_name("all_deps_code_paths"),
Vsn = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
Deps = rebar_test_utils:top_level_deps(
rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}])),
ProfileDeps = rebar_test_utils:top_level_deps(
rebar_test_utils:expand_deps(git, [{"b", "2.0.0", []}])),
RebarConfig = [{deps, Deps},
{profiles,
[{all_deps_test,
[{deps, ProfileDeps}]}]}],
os:putenv("REBAR_PROFILE", "all_deps_test"),
{ok, State} = rebar_test_utils:run_and_check(Config, RebarConfig,
["compile"], {ok, [{app, Name}
,{dep, "a", "1.0.0"}
,{dep, "b", "2.0.0"}]}),
os:unsetenv("REBAR_PROFILE"),
Paths = rebar_state:code_paths(State, all_deps),
Path = lists:reverse(["_build", "all_deps_test", "lib", "b", "ebin"]),
?assert(lists:any(fun(X) ->
Path =:= lists:sublist(lists:reverse(filename:split(X)), 5)
end, Paths)).
profile_merges(_Config) ->
RebarConfig = [{test1, [{key1, 1, 2}, key2]},
{test2, "hello"},
@ -164,7 +199,7 @@ profiles_remain_applied_with_config_present(Config) ->
["as", "not_ok", "compile"], {ok, [{app, Name}]}),
Path = filename:join([AppDir, "_build", "not_ok", "lib", Name, "ebin"]),
code:add_path(Path),
code:add_patha(Path),
Mod = list_to_atom("not_a_real_src_" ++ Name),

Loading…
Cancel
Save