diff options
author | Matwey V. Kornilov <matwey.kornilov@gmail.com> | 2016-02-18 11:40:36 +0300 |
---|---|---|
committer | Matwey V. Kornilov <matwey.kornilov@gmail.com> | 2016-03-14 20:16:43 +0300 |
commit | 7807105138077d9d68777fd31a75f03401ae8026 (patch) | |
tree | c24c7f020a49d6fdd18332e029473255a46dc74e /inttest | |
parent | 2ee235c19b0453269afc2c18ac79605c8c0faaab (diff) | |
download | rebar-7807105138077d9d68777fd31a75f03401ae8026.tar.gz |
Introduce REBAR_DEPS_PREFER_LIBS env variable to alter search behaviour
When REBAR_DEPS_PREFER_LIBS is set, dependencies with defined sources
are allowed to be searched for in system lib directory.
Under specific circumstances (i.e. in build environments without networking)
it is impossible to fetch deps locally. So, user needs a way to ask rebar to
search in system lib directory as well.
Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
Diffstat (limited to 'inttest')
-rw-r--r-- | inttest/tdeps_prefer/a.erl | 4 | ||||
-rw-r--r-- | inttest/tdeps_prefer/a.rebar.config | 4 | ||||
-rw-r--r-- | inttest/tdeps_prefer/b.hrl | 1 | ||||
-rw-r--r-- | inttest/tdeps_prefer/c.hrl | 1 | ||||
-rw-r--r-- | inttest/tdeps_prefer/root.rebar.config | 1 | ||||
-rw-r--r-- | inttest/tdeps_prefer/tdeps_prefer_rt.erl | 68 |
6 files changed, 79 insertions, 0 deletions
diff --git a/inttest/tdeps_prefer/a.erl b/inttest/tdeps_prefer/a.erl new file mode 100644 index 0000000..bf413a6 --- /dev/null +++ b/inttest/tdeps_prefer/a.erl @@ -0,0 +1,4 @@ +-module({{module}}). + +-include_lib("b/include/b.hrl"). +-include_lib("c/include/c.hrl"). diff --git a/inttest/tdeps_prefer/a.rebar.config b/inttest/tdeps_prefer/a.rebar.config new file mode 100644 index 0000000..41fe9bc --- /dev/null +++ b/inttest/tdeps_prefer/a.rebar.config @@ -0,0 +1,4 @@ +{deps, [ + {c, "1", {git, "../repo/c"}}, + {b, "1", {git, "../repo/b"}} +]}. diff --git a/inttest/tdeps_prefer/b.hrl b/inttest/tdeps_prefer/b.hrl new file mode 100644 index 0000000..9f02fab --- /dev/null +++ b/inttest/tdeps_prefer/b.hrl @@ -0,0 +1 @@ +-define(HELLO, hello). diff --git a/inttest/tdeps_prefer/c.hrl b/inttest/tdeps_prefer/c.hrl new file mode 100644 index 0000000..152a99f --- /dev/null +++ b/inttest/tdeps_prefer/c.hrl @@ -0,0 +1 @@ +-define(WORLD, world). diff --git a/inttest/tdeps_prefer/root.rebar.config b/inttest/tdeps_prefer/root.rebar.config new file mode 100644 index 0000000..d1c3793 --- /dev/null +++ b/inttest/tdeps_prefer/root.rebar.config @@ -0,0 +1 @@ +{sub_dirs, ["apps/a"]}. diff --git a/inttest/tdeps_prefer/tdeps_prefer_rt.erl b/inttest/tdeps_prefer/tdeps_prefer_rt.erl new file mode 100644 index 0000000..94c9b8f --- /dev/null +++ b/inttest/tdeps_prefer/tdeps_prefer_rt.erl @@ -0,0 +1,68 @@ +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 et +-module(tdeps_prefer_rt). + +-compile(export_all). + +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + +%% Test REBAR_DEPS_FORCE_LIB +%% A -> [B, C] +%% where B should be found globally and C should be found locally +files() -> + [ + %% A application + {create, "apps/a/ebin/a.app", app(a, [a])}, + {copy, "a.rebar.config", "apps/a/rebar.config"}, + {template, "a.erl", "apps/a/src/a.erl", dict:from_list([{module, a}])}, + + %% B application + {create, "libs/b-1/ebin/b.app", app(b, [])}, + {copy, "b.hrl", "libs/b-1/include/b.hrl"}, + + %% C application + {create, "repo/c/ebin/c.app", app(c, [])}, + {copy, "c.hrl", "repo/c/include/c.hrl"}, + + {copy, "root.rebar.config", "rebar.config"} + ] ++ inttest_utils:rebar_setup(). + +apply_cmds([], _Params) -> + ok; +apply_cmds([Cmd | Rest], Params) -> + io:format("Running: ~s (~p)\n", [Cmd, Params]), + {ok, _} = retest_sh:run(Cmd, Params), + apply_cmds(Rest, Params). + +run(Dir) -> + %% Initialize the c apps as git repos so that dependencies pull + %% properly + GitCmds = ["git init", + "git add -A", + "git config user.email 'tdeps@example.com'", + "git config user.name 'tdeps'", + "git commit -a -m \"Initial Commit\""], + ErlLibs = filename:join(Dir, "libs"), + ok = apply_cmds(GitCmds, [{dir, "repo/c"}]), + Env = [ + {"REBAR_DEPS_PREFER_LIBS", "1"}, + {"ERL_LIBS", ErlLibs} + ], + + {ok, _} = retest_sh:run("./rebar -v get-deps", [{env, Env}]), + {ok, _} = retest_sh:run("./rebar -v compile", [{env, Env}]), + ok. + +%% +%% Generate the contents of a simple .app file +%% +app(Name, Modules) -> + App = {application, Name, + [{description, atom_to_list(Name)}, + {vsn, "1"}, + {modules, Modules}, + {registered, []}, + {applications, [kernel, stdlib]}]}, + io_lib:format("~p.\n", [App]). |