diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mock_pkg_resource.erl | 3 | ||||
-rw-r--r-- | test/rebar_compile_SUITE.erl | 63 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 7 |
3 files changed, 61 insertions, 12 deletions
diff --git a/test/mock_pkg_resource.erl b/test/mock_pkg_resource.erl index 2895cb3..eda863b 100644 --- a/test/mock_pkg_resource.erl +++ b/test/mock_pkg_resource.erl @@ -73,6 +73,7 @@ mock_vsn(_Opts) -> %% into a `rebar.config' file to describe dependencies. mock_download(Opts) -> Deps = proplists:get_value(pkgdeps, Opts, []), + Config = proplists:get_value(config, Opts, []), meck:expect( ?MOD, download, fun (Dir, {pkg, AppBin, Vsn}, _) -> @@ -83,7 +84,7 @@ mock_download(Opts) -> Dir, App, binary_to_list(Vsn), [kernel, stdlib] ++ [element(1,D) || D <- AppDeps] ), - rebar_test_utils:create_config(Dir, [{deps, AppDeps}]), + rebar_test_utils:create_config(Dir, [{deps, AppDeps}]++Config), TarApp = App++"-"++binary_to_list(Vsn)++".tar", Tarball = filename:join([Dir, TarApp]), Contents = filename:join([Dir, "contents.tar.gz"]), diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 2dc57c5..7025eef 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,17 +409,20 @@ 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} - ]}]}]), - mock_pkg_resource:mock([ - {pkgdeps, [{{iolist_to_binary(PluginName), iolist_to_binary(Vsn)}, []}]} - ]), + + Plugins = rebar_test_utils:expand_deps(git, [{PluginName, Vsn, []}]), + mock_git_resource:mock([{deps, rebar_test_utils:flat_deps(Plugins)}]), + + mock_pkg_resource:mock([{pkgdeps, [{{list_to_binary(DepName), list_to_binary(Vsn)}, []}]}, + {config, [{plugins, [ + {list_to_atom(PluginName), + {git, "http://site.com/user/"++PluginName++".git", + {tag, Vsn}}}]}]}]), RConfFile = rebar_test_utils:create_config(AppDir, [{deps, [ - {list_to_atom(DepName), {git, "http://site.com/user/"++DepName++".git", {tag, Vsn}}} + list_to_atom(DepName) ]}]), {ok, RConf} = file:consult(RConfFile), @@ -480,6 +484,49 @@ 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_"), + + Deps = rebar_test_utils:expand_deps(git, [{PluginName, Vsn2, [{DepName2, Vsn, + [{DepName3, Vsn, []}]}]} + ,{DepName, Vsn, []}]), + mock_git_resource:mock([{deps, rebar_test_utils:flat_deps(Deps)}]), + + 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"]), |