diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-05-27 20:01:16 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-05-27 21:56:06 -0500 |
commit | 4ff95cee31cb7d06bd239e4d4ccbf8b59cdebdda (patch) | |
tree | bb270067940ddb3a560d4ef0362f24e7605ce283 /test | |
parent | 20f4562c6dabfcf9df1e52ec2c83307b33c24090 (diff) |
add test for plugin with transitive deps
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_compile_SUITE.erl | 53 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 7 |
2 files changed, 56 insertions, 4 deletions
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 2dc57c5..c48b303 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -20,6 +20,7 @@ checkout_priority/1, compile_plugins/1, compile_global_plugins/1, + complex_plugins/1, highest_version_of_pkg_dep/1, parse_transform_test/1]). @@ -49,7 +50,7 @@ all() -> recompile_when_opts_change, dont_recompile_when_opts_dont_change, dont_recompile_yrl_or_xrl, delete_beam_if_source_deleted, deps_in_path, checkout_priority, compile_plugins, compile_global_plugins, - highest_version_of_pkg_dep, parse_transform_test]. + complex_plugins, highest_version_of_pkg_dep, parse_transform_test]. build_basic_app(Config) -> AppDir = ?config(apps, Config), @@ -408,6 +409,7 @@ compile_plugins(Config) -> DepName = rebar_test_utils:create_random_name("dep1_"), PluginName = rebar_test_utils:create_random_name("plugin1_"), + mock_git_resource:mock([{config, [{plugins, [ {list_to_atom(PluginName), Vsn} ]}]}]), @@ -480,6 +482,55 @@ compile_global_plugins(Config) -> meck:unload(rebar_dir). +%% Tests installing of plugin with transitive deps +complex_plugins(Config) -> + AppDir = ?config(apps, Config), + + meck:new(rebar_dir, [passthrough]), + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + Vsn2 = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + DepName = rebar_test_utils:create_random_name("dep1_"), + DepName2 = rebar_test_utils:create_random_name("dep2_"), + DepName3 = rebar_test_utils:create_random_name("dep3_"), + PluginName = rebar_test_utils:create_random_name("plugin1_"), + + Plugin = {{PluginName, Vsn2}, [{list_to_atom(DepName2), + {git, "http://site.com/user/"++DepName2++".git", {tag, Vsn}}}]}, + Dep2 = {{DepName2, Vsn}, + [{list_to_atom(DepName3), + {git, "http://site.com/user/"++DepName3++".git", {tag, Vsn}}}]}, + mock_git_resource:mock([{deps, [Plugin, + Dep2, + {{iolist_to_binary(DepName), iolist_to_binary(Vsn)}, []}, + {{iolist_to_binary(DepName3), iolist_to_binary(Vsn)}, []}]}]), + + + RConfFile = + rebar_test_utils:create_config(AppDir, + [{deps, [ + {list_to_atom(DepName), {git, "http://site.com/user/"++DepName++".git", {tag, Vsn}}} + ]}, + {plugins, [ + {list_to_atom(PluginName), {git, "http://site.com/user/"++PluginName++".git", {tag, Vsn2}}} + ]}]), + {ok, RConf} = file:consult(RConfFile), + + %% Build with deps. + rebar_test_utils:run_and_check( + Config, RConf, ["compile"], + {ok, [{app, Name}, + {plugin, PluginName, Vsn2}, + {plugin, DepName2}, + {plugin, DepName3}, + {dep, DepName}]} + ), + + meck:unload(rebar_dir). + highest_version_of_pkg_dep(Config) -> AppDir = ?config(apps, Config), diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 68e0603..f53ba20 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -70,7 +70,8 @@ run_and_check(Config, RebarConfig, Command, Expect) -> %% - src/<file>.app.src %% And returns a `rebar_app_info' object. create_app(AppDir, Name, Vsn, Deps) -> - write_src_file(AppDir, Name), + write_src_file(AppDir, Name ++ ".erl"), + write_src_file(AppDir, "not_a_real_src_" ++ Name ++ ".erl"), write_app_src_file(AppDir, Name, Vsn, Deps), rebar_app_info:new(Name, Vsn, AppDir, Deps). @@ -297,9 +298,9 @@ check_results(AppDir, Expected) -> end, Expected). write_src_file(Dir, Name) -> - Erl = filename:join([Dir, "src", "not_a_real_src_" ++ Name ++ ".erl"]), + Erl = filename:join([Dir, "src", Name]), ok = filelib:ensure_dir(Erl), - ok = ec_file:write(Erl, erl_src_file("not_a_real_src_" ++ Name ++ ".erl")). + ok = ec_file:write(Erl, erl_src_file(Name)). write_eunitized_src_file(Dir, Name) -> Erl = filename:join([Dir, "src", "not_a_real_src_" ++ Name ++ ".erl"]), |