2014-12-02 09:52:45 +00:00
|
|
|
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
|
|
|
|
%% ex: ts=4 sw=4 et
|
2013-05-15 22:56:45 +00:00
|
|
|
%%% @doc Plugin handling test
|
|
|
|
%%%
|
|
|
|
%%% This test checks if plugins are loaded correctly.
|
|
|
|
%%%
|
|
|
|
%%% It has three applications:
|
|
|
|
%%% <ol>
|
2013-11-27 16:00:38 +00:00
|
|
|
%%% <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>
|
2013-05-15 22:56:45 +00:00
|
|
|
%%% </ol>
|
|
|
|
|
|
|
|
-module(depplugins_rt).
|
|
|
|
-compile(export_all).
|
|
|
|
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
|
|
|
|
files() ->
|
|
|
|
[
|
|
|
|
{copy, "../../rebar", "rebar"},
|
|
|
|
{copy, "rebar.config", "rebar.config"},
|
2013-11-27 14:12:19 +00:00
|
|
|
{copy, "base_dir_cwd_plugin.erl", "base_dir_cwd_plugin.erl"},
|
2013-05-15 22:56:45 +00:00
|
|
|
{create, "ebin/fish.app", app(fish, [])},
|
|
|
|
|
|
|
|
{copy, "rebar_dependsonplugin.config",
|
2013-11-27 14:12:19 +00:00
|
|
|
"deps/dependsonplugin/rebar.config"},
|
|
|
|
{create, "deps/dependsonplugin/ebin/dependsonplugin.app",
|
|
|
|
app(dependsonplugin, [])},
|
|
|
|
|
|
|
|
{copy, "rebar_testplugin.config", "deps/testplugin/rebar.config"},
|
2013-05-15 22:56:45 +00:00
|
|
|
{copy, "testplugin_mod.erl",
|
2013-11-27 14:12:19 +00:00
|
|
|
"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, [])}
|
2013-05-15 22:56:45 +00:00
|
|
|
].
|
|
|
|
|
|
|
|
run(_Dir) ->
|
|
|
|
?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])),
|
2013-11-27 14:12:19 +00:00
|
|
|
|
|
|
|
?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")),
|
2013-05-15 22:56:45 +00:00
|
|
|
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]).
|