diff options
Diffstat (limited to 'inttest')
-rw-r--r-- | inttest/depplugins/depplugins_rt.erl | 50 | ||||
-rw-r--r-- | inttest/depplugins/rebar.config | 1 | ||||
-rw-r--r-- | inttest/depplugins/rebar_dependsonplugin.config | 2 | ||||
-rw-r--r-- | inttest/depplugins/testplugin_mod.erl | 6 | ||||
-rw-r--r-- | inttest/tdeps1/a.rebar.config | 2 | ||||
-rw-r--r-- | inttest/tdeps1/b.rebar.config | 2 | ||||
-rw-r--r-- | inttest/tdeps1/tdeps1_rt.erl | 19 | ||||
-rw-r--r-- | inttest/tdeps2/a.rebar.config | 2 | ||||
-rw-r--r-- | inttest/tdeps2/b.rebar.config | 2 | ||||
-rw-r--r-- | inttest/tdeps2/tdeps2_rt.erl | 19 |
10 files changed, 93 insertions, 12 deletions
diff --git a/inttest/depplugins/depplugins_rt.erl b/inttest/depplugins/depplugins_rt.erl new file mode 100644 index 0000000..7b106eb --- /dev/null +++ b/inttest/depplugins/depplugins_rt.erl @@ -0,0 +1,50 @@ +%%% @doc Plugin handling test +%%% +%%% This test checks if plugins are loaded correctly. +%%% +%%% 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> +%%% </ol> + +-module(depplugins_rt). +-compile(export_all). + +-include_lib("eunit/include/eunit.hrl"). + +files() -> + [ + {copy, "../../rebar", "rebar"}, + {copy, "rebar.config", "rebar.config"}, + {create, "ebin/fish.app", app(fish, [])}, + + {create, "deps/dependsonplugin/ebin/dependsonplugin.app", + app(dependsonplugin, [])}, + {copy, "rebar_dependsonplugin.config", + "deps/dependsonplugin/rebar.config"}, + {copy, "testplugin_mod.erl", + "deps/testplugin/plugins/testplugin_mod.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")), + 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/depplugins/rebar.config b/inttest/depplugins/rebar.config new file mode 100644 index 0000000..3a2e34e --- /dev/null +++ b/inttest/depplugins/rebar.config @@ -0,0 +1 @@ +{deps, [dependsonplugin]}. diff --git a/inttest/depplugins/rebar_dependsonplugin.config b/inttest/depplugins/rebar_dependsonplugin.config new file mode 100644 index 0000000..df36213 --- /dev/null +++ b/inttest/depplugins/rebar_dependsonplugin.config @@ -0,0 +1,2 @@ +{deps, [testplugin]}. +{plugins, [testplugin_mod]}. diff --git a/inttest/depplugins/testplugin_mod.erl b/inttest/depplugins/testplugin_mod.erl new file mode 100644 index 0000000..055bbc7 --- /dev/null +++ b/inttest/depplugins/testplugin_mod.erl @@ -0,0 +1,6 @@ +-module(testplugin_mod). +-compile(export_all). + +pre_compile(Config, _) -> + ok = file:write_file("pre.compile", <<"Yadda!">>), + rebar_log:log(info, "Wrote ~p/pre.compile~n", [rebar_utils:get_cwd()]). diff --git a/inttest/tdeps1/a.rebar.config b/inttest/tdeps1/a.rebar.config index 01609ee..991ea5a 100644 --- a/inttest/tdeps1/a.rebar.config +++ b/inttest/tdeps1/a.rebar.config @@ -1 +1 @@ -{deps, [{b, "1", {hg, "../repo/b", "tip"}}]}. +{deps, [{b, "1", {git, "../repo/b"}}]}. diff --git a/inttest/tdeps1/b.rebar.config b/inttest/tdeps1/b.rebar.config index 59c8987..ffbd0db 100644 --- a/inttest/tdeps1/b.rebar.config +++ b/inttest/tdeps1/b.rebar.config @@ -1 +1 @@ -{deps, [{c, "1", {hg, "../repo/c", "tip"}}]}. +{deps, [{c, "1", {git, "../repo/c"}}]}. diff --git a/inttest/tdeps1/tdeps1_rt.erl b/inttest/tdeps1/tdeps1_rt.erl index 43184c6..3de1a2b 100644 --- a/inttest/tdeps1/tdeps1_rt.erl +++ b/inttest/tdeps1/tdeps1_rt.erl @@ -23,12 +23,23 @@ files() -> {copy, "c.hrl", "repo/c/include/c.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 mercurial repos so that dependencies pull + %% Initialize the b/c apps as git repos so that dependencies pull %% properly - HgCmd = "/bin/sh -c \"hg init && hg add && hg commit -m 'Initial commit'\"", - {ok, _} = retest_sh:run(HgCmd, [{dir, "repo/b"}]), - {ok, _} = retest_sh:run(HgCmd, [{dir, "repo/c"}]), + 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 compile", []), diff --git a/inttest/tdeps2/a.rebar.config b/inttest/tdeps2/a.rebar.config index 01609ee..991ea5a 100644 --- a/inttest/tdeps2/a.rebar.config +++ b/inttest/tdeps2/a.rebar.config @@ -1 +1 @@ -{deps, [{b, "1", {hg, "../repo/b", "tip"}}]}. +{deps, [{b, "1", {git, "../repo/b"}}]}. diff --git a/inttest/tdeps2/b.rebar.config b/inttest/tdeps2/b.rebar.config index 59c8987..ffbd0db 100644 --- a/inttest/tdeps2/b.rebar.config +++ b/inttest/tdeps2/b.rebar.config @@ -1 +1 @@ -{deps, [{c, "1", {hg, "../repo/c", "tip"}}]}. +{deps, [{c, "1", {git, "../repo/c"}}]}. diff --git a/inttest/tdeps2/tdeps2_rt.erl b/inttest/tdeps2/tdeps2_rt.erl index bad546e..987567e 100644 --- a/inttest/tdeps2/tdeps2_rt.erl +++ b/inttest/tdeps2/tdeps2_rt.erl @@ -31,12 +31,23 @@ files() -> {copy, "c.hrl", "repo/c/include/c.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 mercurial repos so that dependencies pull + %% Initialize the b/c apps as git repos so that dependencies pull %% properly - HgCmd = "/bin/sh -c \"hg init && hg add && hg commit -m 'Initial commit'\"", - {ok, _} = retest_sh:run(HgCmd, [{dir, "repo/b"}]), - {ok, _} = retest_sh:run(HgCmd, [{dir, "repo/c"}]), + 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, _} = retest_sh:run("./rebar -v get-deps compile", []), ok. |