diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_cover_SUITE.erl | 21 | ||||
-rw-r--r-- | test/rebar_install_deps_SUITE.erl | 54 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 12 |
3 files changed, 59 insertions, 28 deletions
diff --git a/test/rebar_cover_SUITE.erl b/test/rebar_cover_SUITE.erl index 0bead99..1fae92c 100644 --- a/test/rebar_cover_SUITE.erl +++ b/test/rebar_cover_SUITE.erl @@ -8,7 +8,6 @@ flag_coverdata_written/1, config_coverdata_written/1, index_written/1, - config_alt_coverdir/1, flag_verbose/1, config_verbose/1]). @@ -31,7 +30,6 @@ init_per_testcase(_, Config) -> all() -> [flag_coverdata_written, config_coverdata_written, index_written, - config_alt_coverdir, flag_verbose, config_verbose]. flag_coverdata_written(Config) -> @@ -79,23 +77,6 @@ index_written(Config) -> true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "index.html"])). -config_alt_coverdir(Config) -> - AppDir = ?config(apps, Config), - - Name = rebar_test_utils:create_random_name("cover_"), - Vsn = rebar_test_utils:create_random_vsn(), - rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]), - - CoverDir = filename:join(["coverage", "goes", "here"]), - - RebarConfig = [{erl_opts, [{d, some_define}]}, {cover_data_dir, CoverDir}], - rebar_test_utils:run_and_check(Config, - RebarConfig, - ["do", "eunit", "--cover", ",", "cover"], - {ok, [{app, Name}]}), - - true = filelib:is_file(filename:join([CoverDir, "index.html"])). - flag_verbose(Config) -> AppDir = ?config(apps, Config), @@ -118,7 +99,7 @@ config_verbose(Config) -> Vsn = rebar_test_utils:create_random_vsn(), rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]), - RebarConfig = [{erl_opts, [{d, some_define}]}, {cover_print_enabled, true}], + RebarConfig = [{erl_opts, [{d, some_define}]}, {cover_opts, [verbose]}], rebar_test_utils:run_and_check(Config, RebarConfig, ["do", "eunit", "--cover", ",", "cover"], diff --git a/test/rebar_install_deps_SUITE.erl b/test/rebar_install_deps_SUITE.erl index dca6308..be42e68 100644 --- a/test/rebar_install_deps_SUITE.erl +++ b/test/rebar_install_deps_SUITE.erl @@ -10,7 +10,8 @@ groups() -> [{all, [], [flat, pick_highest_left, pick_highest_right, pick_smallest1, pick_smallest2, circular1, circular2, circular_skip, - fail_conflict, default_profile, nondefault_profile]}, + fail_conflict, default_profile, nondefault_profile, + nondefault_pick_highest]}, {git, [], [{group, all}]}, {pkg, [], [{group, all}]}]. @@ -125,7 +126,10 @@ deps(nondefault_profile) -> {[{"B", []}, {"C", []}], [], - {ok, ["B", "C"]}}. + {ok, ["B", "C"]}}; +deps(nondefault_pick_highest) -> + %% This is all handled in setup_project + {[],[],{ok,[]}}. setup_project(fail_conflict, Config0, Deps) -> DepsType = ?config(deps_type, Config0), @@ -164,6 +168,34 @@ setup_project(nondefault_profile, Config0, Deps) -> mock_pkg_resource:mock([{pkgdeps, rebar_test_utils:flat_pkgdeps(Deps)}]) end, [{rebarconfig, RebarConf} | Config]; +setup_project(nondefault_pick_highest, Config0, _) -> + DepsType = ?config(deps_type, Config0), + Config = rebar_test_utils:init_rebar_state( + Config0, + "nondefault_pick_highest_"++atom_to_list(DepsType)++"_" + ), + AppDir = ?config(apps, Config), + rebar_test_utils:create_app(AppDir, "A", "0.0.0", [kernel, stdlib]), + DefaultDeps = rebar_test_utils:expand_deps(DepsType, [{"B", [{"C", "1", []}]}]), + ProfileDeps = rebar_test_utils:expand_deps(DepsType, [{"C", "2", []}]), + DefaultTop = rebar_test_utils:top_level_deps(DefaultDeps), + ProfileTop = rebar_test_utils:top_level_deps(ProfileDeps), + RebarConf = rebar_test_utils:create_config( + AppDir, + [{deps, DefaultTop}, + {profiles, [{nondef, [{deps, ProfileTop}]}]}] + ), + case DepsType of + git -> + mock_git_resource:mock( + [{deps, rebar_test_utils:flat_deps(DefaultDeps ++ ProfileDeps)}] + ); + pkg -> + mock_pkg_resource:mock( + [{pkgdeps, rebar_test_utils:flat_pkgdeps(DefaultDeps ++ ProfileDeps)}] + ) + end, + [{rebarconfig, RebarConf} | Config]; setup_project(Case, Config0, Deps) -> DepsType = ?config(deps_type, Config0), Config = rebar_test_utils:init_rebar_state( @@ -228,7 +260,7 @@ default_profile(Config) -> || {dep, App} <- Apps]. nondefault_profile(Config) -> - %% The dependencies here are saved directly to the + %% The dependencies here are saved directly to the {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), AppDir = ?config(apps, Config), {ok, AppLocks} = ?config(expect, Config), @@ -262,6 +294,21 @@ nondefault_profile(Config) -> file:read_file_info(filename:join([BuildDir, "default", "lib", App]))) || {dep, App} <- Apps]. +nondefault_pick_highest(Config) -> + {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), + %AppDir = ?config(apps, Config), + rebar_test_utils:run_and_check( + Config, RebarConfig, ["as", "nondef", "lock"], + {ok, [{dep, "B"}, {lock, "B"}, {dep, "C", "2"}], "nondef"} + ), + rebar_test_utils:run_and_check( + Config, RebarConfig, ["lock"], + {ok, [{dep, "B"}, {lock, "B"}, {dep, "C", "1"}, {lock, "C", "1"}], "default"} + ), + rebar_test_utils:run_and_check( + Config, RebarConfig, ["as", "nondef", "lock"], + {ok, [{dep, "B"}, {lock, "B"}, {dep, "C", "2"}], "nondef"} + ). run(Config) -> {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), @@ -294,4 +341,3 @@ in_warnings(pkg, Warns, NameRaw, VsnRaw) -> Vsn = iolist_to_binary(VsnRaw), 1 =< length([1 || {_, [AppName, AppVsn]} <- Warns, AppName =:= Name, AppVsn =:= Vsn]). - diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 4943d4b..e59ca23 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -56,7 +56,11 @@ run_and_check(Config, RebarConfig, Command, Expect) -> ?assertEqual({error, Reason}, Res); {ok, Expected} -> {ok, _} = Res, - check_results(AppDir, Expected), + check_results(AppDir, Expected, "*"), + Res; + {ok, Expected, ProfileRun} -> + {ok, _} = Res, + check_results(AppDir, Expected, ProfileRun), Res; return -> Res @@ -164,9 +168,9 @@ top_level_deps([{{Name, Vsn, Ref}, _} | Deps]) -> %%%%%%%%%%%%%%% %%% Helpers %%% %%%%%%%%%%%%%%% -check_results(AppDir, Expected) -> - BuildDirs = filelib:wildcard(filename:join([AppDir, "_build", "*", "lib"])), - PluginDirs = filelib:wildcard(filename:join([AppDir, "_build", "*", "plugins"])), +check_results(AppDir, Expected, ProfileRun) -> + BuildDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "lib"])), + PluginDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "plugins"])), GlobalPluginDirs = filelib:wildcard(filename:join([AppDir, "global", "plugins"])), CheckoutsDir = filename:join([AppDir, "_checkouts"]), LockFile = filename:join([AppDir, "rebar.lock"]), |