diff options
Diffstat (limited to 'inttest')
40 files changed, 437 insertions, 17 deletions
diff --git a/inttest/depplugins/base_dir_cwd_plugin.erl b/inttest/depplugins/base_dir_cwd_plugin.erl new file mode 100644 index 0000000..4953b8b --- /dev/null +++ b/inttest/depplugins/base_dir_cwd_plugin.erl @@ -0,0 +1,7 @@ +-module(base_dir_cwd_plugin). +-export([pre_compile/2]). + +pre_compile(_, _) -> + File = "base_dir_cwd_pre.compile", + ok = file:write_file(File, <<"base_dir cwd pre_compile plugin">>), + rebar_log:log(info, "Wrote ~p/~s~n", [rebar_utils:get_cwd(), File]). diff --git a/inttest/depplugins/dep_cwd_plugin.erl b/inttest/depplugins/dep_cwd_plugin.erl new file mode 100644 index 0000000..fe1ceba --- /dev/null +++ b/inttest/depplugins/dep_cwd_plugin.erl @@ -0,0 +1,7 @@ +-module(dep_cwd_plugin). +-export([pre_compile/2]). + +pre_compile(_, _) -> + File = "dep_cwd_pre.compile", + ok = file:write_file(File, <<"dep cwd pre_compile plugin">>), + rebar_log:log(info, "Wrote ~p/~s~n", [rebar_utils:get_cwd(), File]). diff --git a/inttest/depplugins/depplugins_rt.erl b/inttest/depplugins/depplugins_rt.erl index 7b106eb..a45fa93 100644 --- a/inttest/depplugins/depplugins_rt.erl +++ b/inttest/depplugins/depplugins_rt.erl @@ -4,11 +4,14 @@ %%% %%% It has three applications: %%% <ol> -%%% <li>fish. top-level module, has one dependency: `dependsonplugin'.</li> -%%% <li>dependsonplugin. This depends on some pre-compile actions by the -%%% plugin. In the test the plugin creates a file `pre.compile' in the -%%% top-level folder of this application.</li> -%%% <li>testplugin. This is a plugin application which creates the file.</li> +%%% <li>fish. top-level app, has one dependency: `dependsonplugin'. +%%% It also loads a plugin from CWD which creates +%%% base_dir_cwd_pre.compile on pre_compile.</li> +%%% <li>dependsonplugin, has one dependency: `testplugin' and loads +%%% the testplugin_mod plugin.</li> +%%% <li>testplugin. This is a plugin application which creates +%%% plugin_pre.compile on pre_compile. It also loads a plugin from CWD +%%% which creates dep_cwd_pre.compile on pre_compile.</li> %%% </ol> -module(depplugins_rt). @@ -20,21 +23,37 @@ files() -> [ {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, + {copy, "base_dir_cwd_plugin.erl", "base_dir_cwd_plugin.erl"}, {create, "ebin/fish.app", app(fish, [])}, - {create, "deps/dependsonplugin/ebin/dependsonplugin.app", - app(dependsonplugin, [])}, {copy, "rebar_dependsonplugin.config", - "deps/dependsonplugin/rebar.config"}, + "deps/dependsonplugin/rebar.config"}, + {create, "deps/dependsonplugin/ebin/dependsonplugin.app", + app(dependsonplugin, [])}, + + {copy, "rebar_testplugin.config", "deps/testplugin/rebar.config"}, {copy, "testplugin_mod.erl", - "deps/testplugin/plugins/testplugin_mod.erl"}, - {create, "deps/testplugin/ebin/testplugin.app", - app(testplugin, [])} + "deps/testplugin/plugins/testplugin_mod.erl"}, + {copy, "dep_cwd_plugin.erl", "deps/testplugin/dep_cwd_plugin.erl"}, + {create, "deps/testplugin/ebin/testplugin.app", app(testplugin, [])} ]. run(_Dir) -> ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), - ?assertEqual(true, filelib:is_regular("deps/dependsonplugin/pre.compile")), + + ?assertEqual(true, filelib:is_regular("base_dir_cwd_pre.compile")), + + ?assertEqual(true, filelib:is_regular( + "deps/dependsonplugin/base_dir_cwd_pre.compile")), + ?assertEqual(true, filelib:is_regular( + "deps/dependsonplugin/plugin_pre.compile")), + + ?assertEqual(true, filelib:is_regular( + "deps/testplugin/base_dir_cwd_pre.compile")), + ?assertEqual(true, filelib:is_regular( + "deps/testplugin/dep_cwd_pre.compile")), + ?assertEqual(true, filelib:is_regular( + "deps/testplugin/plugin_pre.compile")), ok. %% diff --git a/inttest/depplugins/rebar.config b/inttest/depplugins/rebar.config index 3a2e34e..86fb037 100644 --- a/inttest/depplugins/rebar.config +++ b/inttest/depplugins/rebar.config @@ -1 +1,2 @@ {deps, [dependsonplugin]}. +{plugins, [base_dir_cwd_plugin]}. diff --git a/inttest/depplugins/rebar_testplugin.config b/inttest/depplugins/rebar_testplugin.config new file mode 100644 index 0000000..58a1f99 --- /dev/null +++ b/inttest/depplugins/rebar_testplugin.config @@ -0,0 +1 @@ +{plugins, [dep_cwd_plugin]}. diff --git a/inttest/depplugins/testplugin_mod.erl b/inttest/depplugins/testplugin_mod.erl index 055bbc7..d829ff0 100644 --- a/inttest/depplugins/testplugin_mod.erl +++ b/inttest/depplugins/testplugin_mod.erl @@ -1,6 +1,7 @@ -module(testplugin_mod). --compile(export_all). +-export([pre_compile/2]). -pre_compile(Config, _) -> - ok = file:write_file("pre.compile", <<"Yadda!">>), - rebar_log:log(info, "Wrote ~p/pre.compile~n", [rebar_utils:get_cwd()]). +pre_compile(_, _) -> + File = "plugin_pre.compile", + ok = file:write_file(File, <<"Yadda!">>), + rebar_log:log(info, "Wrote ~p/~s~n", [rebar_utils:get_cwd(), File]). diff --git a/inttest/logging/logging_rt.erl b/inttest/logging/logging_rt.erl new file mode 100644 index 0000000..2b8e54b --- /dev/null +++ b/inttest/logging/logging_rt.erl @@ -0,0 +1,99 @@ +-module(logging_rt). +-export([files/0, + run/1]). + +-define(APP_FILE, "ebin/logging.app"). + +files() -> + [ + {copy, "../../rebar", "rebar"}, + {create, ?APP_FILE, app(invalid_name, [])} + ]. + +run(_Dir) -> + SharedExpected = "==> logging_rt \\(compile\\)", + %% provoke ERROR due to an invalid app file + retest:log(info, "Check 'compile' failure output~n"), + ok = check_output("./rebar compile -q", should_fail, + [SharedExpected, "ERROR: "], + ["WARN: ", "INFO: ", "DEBUG: "]), + %% fix bad app file + ok = file:write_file(?APP_FILE, app(logging, [])), + retest:log(info, "Check 'compile' success output~n"), + ok = check_output("./rebar compile", should_succeed, + [SharedExpected], + ["ERROR: ", "WARN: ", "INFO: ", "DEBUG: "]), + retest:log(info, "Check 'compile -v' success output~n"), + ok = check_output("./rebar compile -v", should_succeed, + [SharedExpected], + ["ERROR: ", "INFO: ", "DEBUG: "]), + retest:log(info, "Check 'compile -vv' success output~n"), + ok = check_output("./rebar compile -vv", should_succeed, + [SharedExpected, "DEBUG: "], + ["ERROR: ", "INFO: "]), + ok. + +check_output(Cmd, FailureMode, Expected, Unexpected) -> + case {retest:sh(Cmd), FailureMode} of + {{error, _}=Error, should_succeed} -> + retest:log(error, "cmd '~s' failed:~n~p~n", [Cmd, Error]), + Error; + {{ok, Captured}, should_succeed} -> + Joined = string:join(Captured, "\n"), + check_output1(Cmd, Joined, Expected, Unexpected); + {{error, {stopped, {_Rc, Captured}}}, should_fail} -> + Joined = string:join(Captured, "\n"), + check_output1(Cmd, Joined, Expected, Unexpected) + end. + +check_output1(Cmd, Captured, Expected, Unexpected) -> + ReOpts = [{capture, all, list}], + ExMatches = + lists:zf( + fun(Pattern) -> + case re:run(Captured, Pattern, ReOpts) of + nomatch -> + retest:log(error, + "Expected pattern '~s' missing " + "in the following output:~n" + "=== BEGIN ===~n~s~n=== END ===~n", + [Pattern, Captured]), + {true, Pattern}; + {match, _} -> + false + end + end, Expected), + + UnExMatches = + lists:zf( + fun(Pattern) -> + case re:run(Captured, Pattern, ReOpts) of + nomatch -> + false; + {match, [Match]} -> + retest:log( + console, + "Unexpected output when running cmd '~s':~n~s~n", + [Cmd, Match]), + {true, Match} + end + end, Unexpected), + + case {ExMatches, UnExMatches} of + {[], []} -> + ok; + _ -> + error + end. + +%% +%% 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/inttest/retest b/inttest/retest Binary files differdeleted file mode 100755 index 4e14bde..0000000 --- a/inttest/retest +++ /dev/null diff --git a/inttest/rgen1/retest.config b/inttest/rgen1/retest.config new file mode 100644 index 0000000..b569f14 --- /dev/null +++ b/inttest/rgen1/retest.config @@ -0,0 +1 @@ +{timeout, 120000}. diff --git a/inttest/t_custom_config/t_custom_config_rt.erl b/inttest/t_custom_config/t_custom_config_rt.erl index 864ce5e..b56eb1a 100644 --- a/inttest/t_custom_config/t_custom_config_rt.erl +++ b/inttest/t_custom_config/t_custom_config_rt.erl @@ -11,7 +11,7 @@ files() -> run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), - Ref = retest:sh("./rebar -C custom.config check-deps -vvv", + Ref = retest:sh("./rebar -C custom.config check-deps -vv", [{async, true}]), {ok, Captured} = retest:sh_expect(Ref, diff --git a/inttest/tdeps3/a.erl b/inttest/tdeps3/a.erl new file mode 100644 index 0000000..5a387eb --- /dev/null +++ b/inttest/tdeps3/a.erl @@ -0,0 +1,3 @@ +-module({{module}}). + +-include_lib("{{dep}}/include/{{dep}}.hrl"). diff --git a/inttest/tdeps3/a.rebar.config b/inttest/tdeps3/a.rebar.config new file mode 100644 index 0000000..19b8ef8 --- /dev/null +++ b/inttest/tdeps3/a.rebar.config @@ -0,0 +1,4 @@ +{deps, [ + {b, "1", {git, "../repo/b"}}, + {f, "1", {git, "../repo/f"}} +]}. diff --git a/inttest/tdeps3/b.hrl b/inttest/tdeps3/b.hrl new file mode 100644 index 0000000..efbeab1 --- /dev/null +++ b/inttest/tdeps3/b.hrl @@ -0,0 +1 @@ +-include_lib("c/include/c.hrl"). diff --git a/inttest/tdeps3/b.rebar.config b/inttest/tdeps3/b.rebar.config new file mode 100644 index 0000000..d1ccae2 --- /dev/null +++ b/inttest/tdeps3/b.rebar.config @@ -0,0 +1,5 @@ +{deps, [ + {c, "1", {git, "../repo/c"}} +]}. + +{lib_dirs, [apps]}. diff --git a/inttest/tdeps3/c.hrl b/inttest/tdeps3/c.hrl new file mode 100644 index 0000000..cc87fff --- /dev/null +++ b/inttest/tdeps3/c.hrl @@ -0,0 +1 @@ +-include_lib("d/include/d.hrl"). diff --git a/inttest/tdeps3/c.rebar.config b/inttest/tdeps3/c.rebar.config new file mode 100644 index 0000000..b590771 --- /dev/null +++ b/inttest/tdeps3/c.rebar.config @@ -0,0 +1 @@ +{deps, [{d, "1", {git, "../repo/d"}}]}. diff --git a/inttest/tdeps3/d.hrl b/inttest/tdeps3/d.hrl new file mode 100644 index 0000000..02f8088 --- /dev/null +++ b/inttest/tdeps3/d.hrl @@ -0,0 +1 @@ +-include_lib("e/include/e.hrl"). diff --git a/inttest/tdeps3/d.rebar.config b/inttest/tdeps3/d.rebar.config new file mode 100644 index 0000000..4c7cd54 --- /dev/null +++ b/inttest/tdeps3/d.rebar.config @@ -0,0 +1 @@ +{deps, [{e, "1", {git, "../repo/e"}}]}. diff --git a/inttest/tdeps3/e.hrl b/inttest/tdeps3/e.hrl new file mode 100644 index 0000000..9f02fab --- /dev/null +++ b/inttest/tdeps3/e.hrl @@ -0,0 +1 @@ +-define(HELLO, hello). diff --git a/inttest/tdeps3/f.hrl b/inttest/tdeps3/f.hrl new file mode 100644 index 0000000..02f8088 --- /dev/null +++ b/inttest/tdeps3/f.hrl @@ -0,0 +1 @@ +-include_lib("e/include/e.hrl"). diff --git a/inttest/tdeps3/root.rebar.config b/inttest/tdeps3/root.rebar.config new file mode 100644 index 0000000..d1c3793 --- /dev/null +++ b/inttest/tdeps3/root.rebar.config @@ -0,0 +1 @@ +{sub_dirs, ["apps/a"]}. diff --git a/inttest/tdeps3/tdeps3_rt.erl b/inttest/tdeps3/tdeps3_rt.erl new file mode 100644 index 0000000..da87d43 --- /dev/null +++ b/inttest/tdeps3/tdeps3_rt.erl @@ -0,0 +1,89 @@ +-module(tdeps3_rt). + +-compile(export_all). + +%% Exercise transitive dependencies where there are multiple files +%% depending on the same set of deps as well as lib_dir directives +%% A -> B -> C -> D -> E +%% |--> G(via lib_dir) +%% |--> F -> D -> E + +files() -> + [ + %% A1 application + {create, "ebin/a.app", app(a, [a])}, + {template, "a.erl", "src/a.erl", dict:from_list([{module, a}, {dep, b}])}, + + {copy, "a.rebar.config", "rebar.config"}, + {copy, "../../rebar", "rebar"}, + + %% B application + {create, "repo/b/ebin/b.app", app(b, [b])}, + {template, "a.erl", "repo/b/src/b.erl", dict:from_list([{module, b}, {dep, b}])}, + {copy, "b.rebar.config", "repo/b/rebar.config"}, + {copy, "b.hrl", "repo/b/include/b.hrl"}, + + %% C application + {create, "repo/c/ebin/c.app", app(c, [c])}, + {template, "a.erl", "repo/c/src/c.erl", dict:from_list([{module, c}, {dep, d}])}, + {copy, "c.rebar.config", "repo/c/rebar.config"}, + {copy, "c.hrl", "repo/c/include/c.hrl"}, + + %% D application + {create, "repo/d/ebin/d.app", app(d, [d])}, + {template, "a.erl", "repo/d/src/d.erl", dict:from_list([{module, d}, {dep, e}])}, + {copy, "d.rebar.config", "repo/d/rebar.config"}, + {copy, "d.hrl", "repo/d/include/d.hrl"}, + + %% E application + {create, "repo/e/ebin/e.app", app(e, [])}, + {copy, "e.hrl", "repo/e/include/e.hrl"}, + + + %% F application + {create, "repo/f/ebin/f.app", app(f, [f])}, + {template, "a.erl", "repo/f/src/f.erl", dict:from_list([{module, f}, {dep, d}])}, + {copy, "c.rebar.config", "repo/f/rebar.config"}, + {copy, "f.hrl", "repo/f/include/f.hrl"}, + + %% G application, which is part of the B repo, in a lib_dir + {create, "repo/b/apps/g/ebin/g.app", app(g, [])}, + {copy, "e.hrl", "repo/b/apps/g/include/g.hrl"} + + ]. + +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 b/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'"], + ok = apply_cmds(GitCmds, [{dir, "repo/b"}]), + ok = apply_cmds(GitCmds, [{dir, "repo/c"}]), + ok = apply_cmds(GitCmds, [{dir, "repo/d"}]), + ok = apply_cmds(GitCmds, [{dir, "repo/e"}]), + ok = apply_cmds(GitCmds, [{dir, "repo/f"}]), + + {ok, _} = retest_sh:run("./rebar -v get-deps compile", []), + 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/inttest/tdeps_update/a.erl b/inttest/tdeps_update/a.erl new file mode 100644 index 0000000..294ae21 --- /dev/null +++ b/inttest/tdeps_update/a.erl @@ -0,0 +1,3 @@ +-module({{module}}). + +-include_lib("b/include/b.hrl"). diff --git a/inttest/tdeps_update/a.rebar.config b/inttest/tdeps_update/a.rebar.config new file mode 100644 index 0000000..3b721dc --- /dev/null +++ b/inttest/tdeps_update/a.rebar.config @@ -0,0 +1 @@ +{deps, [{b, "0.2.3", {git, "../repo/b", {tag, "0.2.3"}}}]}. diff --git a/inttest/tdeps_update/a2.rebar.config b/inttest/tdeps_update/a2.rebar.config new file mode 100644 index 0000000..5687349 --- /dev/null +++ b/inttest/tdeps_update/a2.rebar.config @@ -0,0 +1 @@ +{deps, [{b, "0.2.4", {git, "../repo/b", {tag, "0.2.4"}}}]}. diff --git a/inttest/tdeps_update/a3.rebar.config b/inttest/tdeps_update/a3.rebar.config new file mode 100644 index 0000000..86bf462 --- /dev/null +++ b/inttest/tdeps_update/a3.rebar.config @@ -0,0 +1 @@ +{deps, [{b, "0.2.5", {git, "../repo/b", {tag, "0.2.5"}}}]}. diff --git a/inttest/tdeps_update/a4.rebar.config b/inttest/tdeps_update/a4.rebar.config new file mode 100644 index 0000000..bfba813 --- /dev/null +++ b/inttest/tdeps_update/a4.rebar.config @@ -0,0 +1,4 @@ +{deps, [ + {b, "0.2.6", {git, "../repo/b", {tag, "0.2.6"}}}, + {f, "0.1", {git, "../repo/f", {tag, "0.1"}}} + ]}. diff --git a/inttest/tdeps_update/b.hrl b/inttest/tdeps_update/b.hrl new file mode 100644 index 0000000..efbeab1 --- /dev/null +++ b/inttest/tdeps_update/b.hrl @@ -0,0 +1 @@ +-include_lib("c/include/c.hrl"). diff --git a/inttest/tdeps_update/b.rebar.config b/inttest/tdeps_update/b.rebar.config new file mode 100644 index 0000000..536aaa9 --- /dev/null +++ b/inttest/tdeps_update/b.rebar.config @@ -0,0 +1 @@ +{deps, [{c, "1.0", {git, "../repo/c", {tag, "1.0"}}}]}. diff --git a/inttest/tdeps_update/b2.rebar.config b/inttest/tdeps_update/b2.rebar.config new file mode 100644 index 0000000..b603277 --- /dev/null +++ b/inttest/tdeps_update/b2.rebar.config @@ -0,0 +1 @@ +{deps, [{c, "1.1", {git, "../repo/c", {tag, "1.1"}}}]}. diff --git a/inttest/tdeps_update/b3.rebar.config b/inttest/tdeps_update/b3.rebar.config new file mode 100644 index 0000000..5f4e20a --- /dev/null +++ b/inttest/tdeps_update/b3.rebar.config @@ -0,0 +1 @@ +{deps, [{c, "1.2", {git, "../repo/c", {tag, "1.2"}}}]}. diff --git a/inttest/tdeps_update/b4.rebar.config b/inttest/tdeps_update/b4.rebar.config new file mode 100644 index 0000000..5fd1dca --- /dev/null +++ b/inttest/tdeps_update/b4.rebar.config @@ -0,0 +1 @@ +{deps, [{c, "1.3", {git, "../repo/c", {tag, "1.3"}}}]}. diff --git a/inttest/tdeps_update/c.hrl b/inttest/tdeps_update/c.hrl new file mode 100644 index 0000000..9f02fab --- /dev/null +++ b/inttest/tdeps_update/c.hrl @@ -0,0 +1 @@ +-define(HELLO, hello). diff --git a/inttest/tdeps_update/c.rebar.config b/inttest/tdeps_update/c.rebar.config new file mode 100644 index 0000000..d99b963 --- /dev/null +++ b/inttest/tdeps_update/c.rebar.config @@ -0,0 +1 @@ +{deps, [{d, "0.7", {git, "../repo/d", {tag, "0.7"}}}]}. diff --git a/inttest/tdeps_update/c2.hrl b/inttest/tdeps_update/c2.hrl new file mode 100644 index 0000000..cc87fff --- /dev/null +++ b/inttest/tdeps_update/c2.hrl @@ -0,0 +1 @@ +-include_lib("d/include/d.hrl"). diff --git a/inttest/tdeps_update/c2.rebar.config b/inttest/tdeps_update/c2.rebar.config new file mode 100644 index 0000000..1297e07 --- /dev/null +++ b/inttest/tdeps_update/c2.rebar.config @@ -0,0 +1,4 @@ +{deps, [ + {d, "0.7", {git, "../repo/d", {tag, "0.7"}}}, + {e, "2.0", {git, "../repo/e", {tag, "2.0"}}} + ]}. diff --git a/inttest/tdeps_update/c3.rebar.config b/inttest/tdeps_update/c3.rebar.config new file mode 100644 index 0000000..40c93c5 --- /dev/null +++ b/inttest/tdeps_update/c3.rebar.config @@ -0,0 +1,4 @@ +{deps, [ + {d, "0.7", {git, "../repo/d", {tag, "0.7"}}}, + {e, "2.1", {git, "../repo/e", {tag, "2.1"}}} + ]}. diff --git a/inttest/tdeps_update/d.hrl b/inttest/tdeps_update/d.hrl new file mode 100644 index 0000000..9f02fab --- /dev/null +++ b/inttest/tdeps_update/d.hrl @@ -0,0 +1 @@ +-define(HELLO, hello). diff --git a/inttest/tdeps_update/root.rebar.config b/inttest/tdeps_update/root.rebar.config new file mode 100644 index 0000000..ea03437 --- /dev/null +++ b/inttest/tdeps_update/root.rebar.config @@ -0,0 +1 @@ +{sub_dirs, ["apps/a1"]}. diff --git a/inttest/tdeps_update/tdeps_update_rt.erl b/inttest/tdeps_update/tdeps_update_rt.erl new file mode 100644 index 0000000..81bb7ef --- /dev/null +++ b/inttest/tdeps_update/tdeps_update_rt.erl @@ -0,0 +1,147 @@ +-module(tdeps_update_rt). + +-compile(export_all). + +%% Exercises update deps, with recursive dependency updates. +%% Initially: +%% A(v0.5) -> B(v0.2.3) -> C(v1.0) +%% But after updating A to 0.6: +%% A(v0.6) -> B(v0.2.4) -> C(v1.1) +%% -> D(v0.7) +%% And after updating A to 0.7: +%% A(v0.7) -> B(v0.2.5) -> C(v1.2) -> E(v2.0) +%% -> D(v0.7) +%% And after updating A to 0.8: +%% A(v0.8) -> B(v0.2.6) -> C(v1.3) -> E(v2.1) +%% -> D(v0.7) +%% -> F(v0.1) -> E(v2.1) +files() -> + [ + %% A1 application + {create, "apps/a1/ebin/a1.app", app(a1, [a1], "0.5")}, + {copy, "a.rebar.config", "apps/a1/rebar.config"}, + {template, "a.erl", "apps/a1/src/a1.erl", dict:from_list([{module, a1}])}, + + {copy, "root.rebar.config", "rebar.config"}, + {copy, "../../rebar", "rebar"}, + + %% B application + {create, "repo/b/ebin/b.app", app(b, [], "0.2.3")}, + {create, "b2.app", app(b, [], "0.2.4")}, + {create, "b3.app", app(b, [], "0.2.5")}, + {create, "b4.app", app(b, [], "0.2.6")}, + {copy, "b.rebar.config", "repo/b/rebar.config"}, + {copy, "b.hrl", "repo/b/include/b.hrl"}, + + %% C application + {create, "repo/c/ebin/c.app", app(c, [], "1.0")}, + {create, "c2.app", app(c, [], "1.1")}, + {create, "c3.app", app(c, [], "1.2")}, + {create, "c4.app", app(c, [], "1.3")}, + {copy, "c.hrl", "repo/c/include/c.hrl"}, + + %% D application + {create, "repo/d/ebin/d.app", app(d, [], "0.7")}, + {copy, "d.hrl", "repo/d/include/d.hrl"}, + + %% E application + {create, "repo/e/ebin/e.app", app(e, [], "2.0")}, + {create, "e2.app", app(e, [], "2.1")}, + + %% F application + {create, "repo/f/ebin/f.app", app(f, [], "0.1")}, + + %% update files + {copy, "a2.rebar.config", "a2.rebar.config"}, + {copy, "a3.rebar.config", "a3.rebar.config"}, + {copy, "a4.rebar.config", "a4.rebar.config"}, + {copy, "b2.rebar.config", "b2.rebar.config"}, + {copy, "b3.rebar.config", "b3.rebar.config"}, + {copy, "b4.rebar.config", "b4.rebar.config"}, + {copy, "c2.hrl", "c2.hrl"}, + {copy, "c.rebar.config", "c.rebar.config"}, + {copy, "c2.rebar.config", "c2.rebar.config"}, + {copy, "c3.rebar.config", "c3.rebar.config"} + ]. + +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 b/c/d 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'"], + BCmds = ["git tag 0.2.3", + "cp ../../b2.rebar.config rebar.config", + "cp ../../b2.app ebin/b.app", + "git commit -a -m 'update to 0.2.4'", + "git tag 0.2.4", + "cp ../../b3.rebar.config rebar.config", + "cp ../../b3.app ebin/b.app", + "git commit -a -m 'update to 0.2.5'", + "git tag 0.2.5", + "cp ../../b4.rebar.config rebar.config", + "cp ../../b4.app ebin/b.app", + "git commit -a -m 'update to 0.2.6'", + "git tag 0.2.6"], + %"git checkout 0.2.3"], + CCmds = ["git tag 1.0", + "cp ../../c2.hrl include/c.hrl", + "cp ../../c2.app ebin/c.app", + "cp ../../c.rebar.config rebar.config", + "git add rebar.config", + "git commit -a -m 'update to 1.1'", + "git tag 1.1", + "cp ../../c3.app ebin/c.app", + "cp ../../c2.rebar.config rebar.config", + "git commit -a -m 'update to 1.2'", + "git tag 1.2", + "cp ../../c4.app ebin/c.app", + "cp ../../c3.rebar.config rebar.config", + "git commit -a -m 'update to 1.3'", + "git tag 1.3"], + %"git checkout 1.0"], + DCmds = ["git tag 0.7"], + ECmds = ["git tag 2.0", + "cp ../../e2.app ebin/e.app", + "git commit -a -m 'update to 2.1'", + "git tag 2.1"], + FCmds = ["git tag 0.1"], + + ok = apply_cmds(GitCmds++BCmds, [{dir, "repo/b"}]), + ok = apply_cmds(GitCmds++CCmds, [{dir, "repo/c"}]), + ok = apply_cmds(GitCmds++DCmds, [{dir, "repo/d"}]), + ok = apply_cmds(GitCmds++ECmds, [{dir, "repo/e"}]), + ok = apply_cmds(GitCmds++FCmds, [{dir, "repo/f"}]), + + {ok, _} = retest_sh:run("./rebar -v get-deps compile", []), + os:cmd("cp a2.rebar.config apps/a1/rebar.config"), + {ok, _} = retest_sh:run("./rebar -v update-deps", []), + {ok, _} = retest_sh:run("./rebar -v compile", []), + os:cmd("cp a3.rebar.config apps/a1/rebar.config"), + {ok, _} = retest_sh:run("./rebar -v update-deps", []), + {ok, _} = retest_sh:run("./rebar -v compile", []), + os:cmd("cp a4.rebar.config apps/a1/rebar.config"), + {ok, _} = retest_sh:run("./rebar -v update-deps", []), + {ok, _} = retest_sh:run("./rebar -v compile", []), + ok. + +%% +%% Generate the contents of a simple .app file +%% +app(Name, Modules, Version) -> + App = {application, Name, + [{description, atom_to_list(Name)}, + {vsn, Version}, + {modules, Modules}, + {registered, []}, + {applications, [kernel, stdlib]}]}, + io_lib:format("~p.\n", [App]). |