summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2015-05-20 19:16:17 -0500
committerTristan Sloughter <t@crashfast.com>2015-05-21 17:25:11 -0500
commite65ad8c2cad285ba481ea532203b8f92482621fe (patch)
tree4aab81e725b916fe9d8090a956b9017e366ce330 /test
parent62c9c661826f55093d74055dc7bcc4c72d5bcba9 (diff)
run hooks when building plugins
Diffstat (limited to 'test')
-rw-r--r--test/rebar_hooks_SUITE.erl30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/rebar_hooks_SUITE.erl b/test/rebar_hooks_SUITE.erl
index a5136e5..7df4ea3 100644
--- a/test/rebar_hooks_SUITE.erl
+++ b/test/rebar_hooks_SUITE.erl
@@ -4,9 +4,11 @@
init_per_suite/1,
end_per_suite/1,
init_per_testcase/2,
+ end_per_testcase/2,
all/0,
build_and_clean_app/1,
run_hooks_once/1,
+ run_hooks_for_plugins/1,
deps_hook_namespace/1]).
-include_lib("common_test/include/ct.hrl").
@@ -25,9 +27,12 @@ end_per_suite(_Config) ->
init_per_testcase(_, Config) ->
rebar_test_utils:init_rebar_state(Config).
+end_per_testcase(_, _Config) ->
+ catch meck:unload().
+
all() ->
[build_and_clean_app, run_hooks_once,
- deps_hook_namespace].
+ run_hooks_for_plugins, deps_hook_namespace].
%% Test post provider hook cleans compiled project app, leaving it invalid
build_and_clean_app(Config) ->
@@ -71,3 +76,26 @@ deps_hook_namespace(Config) ->
Config, RebarConfig, ["compile"],
{ok, [{dep, "some_dep"}]}
).
+
+run_hooks_for_plugins(Config) ->
+ AppDir = ?config(apps, Config),
+
+ Name = rebar_test_utils:create_random_name("app1_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ PluginName = rebar_test_utils:create_random_name("plugin1_"),
+ mock_git_resource:mock([{config, [{pre_hooks, [{compile, "touch randomfile"}]}]}]),
+
+ RConfFile = rebar_test_utils:create_config(AppDir,
+ [{plugins, [
+ {list_to_atom(PluginName),
+ {git, "http://site.com/user/"++PluginName++".git",
+ {tag, Vsn}}}
+ ]}]),
+ {ok, RConf} = file:consult(RConfFile),
+
+ rebar_test_utils:run_and_check(Config, RConf, ["compile"], {ok, [{app, Name, valid},
+ {plugin, PluginName},
+ {file, filename:join([AppDir, "_build", "default", "plugins", PluginName, "randomfile"])}]}).