summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Rascão <luis.rascao@gmail.com>2016-04-10 00:12:32 +0100
committerLuis Rascão <luis.rascao@gmail.com>2016-04-10 00:12:32 +0100
commit78b884c768b731ef816645eab3d3bbd81ec918c8 (patch)
tree7724a333624b9e904b9ab2b624588b254207a741
parentef73556df92dd3b31daaf1cc6d97fb220dfcaa0c (diff)
parent27d0f6166a1328fdeb1a5974e6b7e91a97e13f56 (diff)
downloadrebar-78b884c768b731ef816645eab3d3bbd81ec918c8.tar.gz
Merge pull request #602 from choptastic/rebar3-deps
Support full-source rebar3-style deps (deps without Version Regexes)
-rw-r--r--inttest/rebar3_deps1/a.erl8
-rw-r--r--inttest/rebar3_deps1/a.rebar.config4
-rw-r--r--inttest/rebar3_deps1/b.hrl1
-rw-r--r--inttest/rebar3_deps1/c.txt1
-rw-r--r--inttest/rebar3_deps1/rebar3_deps1_rt.erl63
-rw-r--r--src/rebar_deps.erl13
6 files changed, 90 insertions, 0 deletions
diff --git a/inttest/rebar3_deps1/a.erl b/inttest/rebar3_deps1/a.erl
new file mode 100644
index 0000000..835522a
--- /dev/null
+++ b/inttest/rebar3_deps1/a.erl
@@ -0,0 +1,8 @@
+-module(a).
+
+-compile(export_all).
+
+-include_lib("b/include/b.hrl").
+
+hello() ->
+ io:format("~s\n", [?HELLO]).
diff --git a/inttest/rebar3_deps1/a.rebar.config b/inttest/rebar3_deps1/a.rebar.config
new file mode 100644
index 0000000..de3abe3
--- /dev/null
+++ b/inttest/rebar3_deps1/a.rebar.config
@@ -0,0 +1,4 @@
+{deps, [
+ {b, {git, "../repo/b"}},
+ {c, {git, "../repo/c"}, [raw]}
+]}.
diff --git a/inttest/rebar3_deps1/b.hrl b/inttest/rebar3_deps1/b.hrl
new file mode 100644
index 0000000..25dfeda
--- /dev/null
+++ b/inttest/rebar3_deps1/b.hrl
@@ -0,0 +1 @@
+-define(HELLO, "Hi From B").
diff --git a/inttest/rebar3_deps1/c.txt b/inttest/rebar3_deps1/c.txt
new file mode 100644
index 0000000..5adcd3d
--- /dev/null
+++ b/inttest/rebar3_deps1/c.txt
@@ -0,0 +1 @@
+This is a text file.
diff --git a/inttest/rebar3_deps1/rebar3_deps1_rt.erl b/inttest/rebar3_deps1/rebar3_deps1_rt.erl
new file mode 100644
index 0000000..e84b6ba
--- /dev/null
+++ b/inttest/rebar3_deps1/rebar3_deps1_rt.erl
@@ -0,0 +1,63 @@
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+-module(rebar3_deps1_rt).
+
+-compile(export_all).
+
+setup([Target]) ->
+ retest_utils:load_module(filename:join(Target, "inttest_utils.erl")),
+ ok.
+
+%% Test deps with rebar3-type dependencies (that is, dependencies without Regexes)
+%% Example: {git, {appname, "git://something/something", {branch, master}}}
+files() ->
+ [
+ %% A application
+ {create, "ebin/a.app", app(a, [a])},
+ {copy, "a.rebar.config", "rebar.config"},
+ {copy, "a.erl", "src/a.erl"},
+
+ %% B application
+ {create, "repo/b/ebin/b.app", app(b, [])},
+ {copy, "b.hrl", "repo/b/include/b.hrl"},
+
+ {copy, "c.txt", "repo/c/c.txt"}
+
+ ] ++ 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 dep app 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\""],
+ apply_cmds(GitCmds, [{dir, "repo/b"}]),
+ apply_cmds(GitCmds, [{dir, "repo/c"}]),
+
+ {ok, _} = retest_sh:run("./rebar get-deps", []),
+ {ok, _} = retest_sh:run("./rebar compile", []),
+
+ true = filelib:is_regular("ebin/a.beam"),
+ true = filelib:is_regular("deps/c/c.txt"),
+ 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]).
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl
index 995ce97..251bdee 100644
--- a/src/rebar_deps.erl
+++ b/src/rebar_deps.erl
@@ -268,15 +268,24 @@ info_help(Description) ->
{rebar, "1.0.*"},
{rebar, ".*",
{git, "git://github.com/rebar/rebar.git"}},
+ {rebar,
+ {git, "git://github.com/rebar/rebar.git"}},
{rebar, ".*",
{git, "git://github.com/rebar/rebar.git", "Rev"}},
+ {rebar,
+ {git, "git://github.com/rebar/rebar.git", "Rev"}},
{rebar, "1.0.*",
{git, "git://github.com/rebar/rebar.git", {branch, "master"}}},
+ {rebar,
+ {git, "git://github.com/rebar/rebar.git", {branch, "master"}}},
{rebar, "1.0.0",
{git, "git://github.com/rebar/rebar.git", {tag, "1.0.0"}}},
{rebar, "",
{git, "git://github.com/rebar/rebar.git", {branch, "master"}},
[raw]},
+ {rebar,
+ {git, "git://github.com/rebar/rebar.git", {branch, "master"}},
+ [raw]},
{app_name, ".*", {hg, "https://www.example.org/url"}},
{app_name, ".*", {rsync, "Url"}},
{app_name, ".*", {svn, "https://www.example.org/url"}},
@@ -371,8 +380,12 @@ find_deps(Config, read, [], Deps) ->
{Config, lists:reverse(Deps)};
find_deps(Config, Mode, [App | Rest], Acc) when is_atom(App) ->
find_deps(Config, Mode, [{App, ".*", undefined} | Rest], Acc);
+find_deps(Config, Mode, [{App, Source} | Rest], Acc) when is_tuple(Source) ->
+ find_deps(Config, Mode, [{App, ".*", Source} | Rest], Acc);
find_deps(Config, Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) ->
find_deps(Config, Mode, [{App, VsnRegex, undefined} | Rest], Acc);
+find_deps(Config, Mode, [{App, Source, Opts} | Rest], Acc) when is_tuple(Source) ->
+ find_deps(Config, Mode, [{App, ".*", Source, Opts} | Rest], Acc);
find_deps(Config, Mode, [{App, VsnRegex, Source} | Rest], Acc) ->
find_deps(Config, Mode, [{App, VsnRegex, Source, []} | Rest], Acc);
find_deps(Config, Mode, [{App, VsnRegex, Source, Opts} | Rest], Acc)