From 1b422b921b8921128213b29423a48cd7b2c8e417 Mon Sep 17 00:00:00 2001 From: Ted Burghart Date: Mon, 5 Dec 2016 13:22:35 -0500 Subject: Added regression tests for PR 1398 --- test/rebar_profiles_SUITE.erl | 104 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index a31a4c9..ed492a9 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -20,7 +20,12 @@ test_profile_applied_at_completion/1, test_profile_applied_before_compile/1, test_profile_applied_before_eunit/1, - test_profile_applied_to_apps/1]). + test_profile_applied_to_apps/1, + test_profile_erl_opts_order_1/1, + test_profile_erl_opts_order_2/1, + test_profile_erl_opts_order_3/1, + test_profile_erl_opts_order_4/1, + test_profile_erl_opts_order_5/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -36,7 +41,12 @@ all() -> test_profile_applied_at_completion, test_profile_applied_before_compile, test_profile_applied_before_eunit, - test_profile_applied_to_apps]. + test_profile_applied_to_apps, + test_profile_erl_opts_order_1, + test_profile_erl_opts_order_2, + test_profile_erl_opts_order_3, + test_profile_erl_opts_order_4, + test_profile_erl_opts_order_5]. init_per_suite(Config) -> application:start(meck), @@ -432,3 +442,93 @@ test_profile_applied_to_apps(Config) -> ErlOpts = dict:fetch(erl_opts, Opts), true = lists:member({d, 'TEST'}, ErlOpts) end, Apps). + +test_profile_erl_opts_order_1(Config) -> + Opts = get_compiled_profile_erl_opts([default], Config), + Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), + undefined = Opt. + +test_profile_erl_opts_order_2(Config) -> + Opts = get_compiled_profile_erl_opts([strict], Config), + Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), + warn_export_all = Opt. + +test_profile_erl_opts_order_3(Config) -> + Opts = get_compiled_profile_erl_opts([loose], Config), + Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), + nowarn_export_all = Opt. + +test_profile_erl_opts_order_4(Config) -> + Opts = get_compiled_profile_erl_opts([strict, loose], Config), + Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), + nowarn_export_all = Opt. + +test_profile_erl_opts_order_5(Config) -> + Opts = get_compiled_profile_erl_opts([loose, strict], Config), + Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), + warn_export_all = Opt. + +get_compiled_profile_erl_opts(Profiles, Config) -> + AppDir = ?config(apps, Config), + PStrs = [atom_to_list(P) || P <- Profiles], + + Name = rebar_test_utils:create_random_name( + lists:flatten(["erl_opts_order_" | [[S, $_] || S <- PStrs]])), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + RebarConfig = [ + {erl_opts, [warnings_as_errors, {d, profile_default}]}, + {profiles, [ + {strict, [{erl_opts, [warn_export_all, {d, profile_strict}]}]}, + {loose, [{erl_opts, [nowarn_export_all, {d, profile_loose}]}]} ]}], + rebar_test_utils:create_config(AppDir, RebarConfig), + + Command = case Profiles of + [] -> + ["compile"]; + [default] -> + ["compile"]; + _ -> + ["as", string:join(PStrs, ","), "compile"] + end, + {ok, State} = rebar_test_utils:run_and_check( + Config, RebarConfig, Command, {ok, [{app, Name}]}), + code:add_paths(rebar_state:code_paths(State, all_deps)), + Mod = list_to_atom(Name), + proplists:get_value(options, Mod:module_info(compile), []). + +% macro definitions get special handling +last_erl_opt([{d, Macro} = Opt | Opts], Targets, Last) -> + case lists:any(erl_opt_macro_match_fun(Macro), Targets) of + true -> + last_erl_opt(Opts, Targets, Opt); + _ -> + last_erl_opt(Opts, Targets, Last) + end; +last_erl_opt([{d, Macro, _} = Opt | Opts], Targets, Last) -> + case lists:any(erl_opt_macro_match_fun(Macro), Targets) of + true -> + last_erl_opt(Opts, Targets, Opt); + _ -> + last_erl_opt(Opts, Targets, Last) + end; +last_erl_opt([Opt | Opts], Targets, Last) -> + case lists:member(Opt, Targets) of + true -> + last_erl_opt(Opts, Targets, Opt); + _ -> + last_erl_opt(Opts, Targets, Last) + end; +last_erl_opt([], _, Last) -> + Last. + +erl_opt_macro_match_fun(Macro) -> + fun({d, M}) -> + M == Macro; + ({d, M, _}) -> + M == Macro; + (_) -> + false + end. + -- cgit v1.1 From 1783df5ad3ff0e632aedc2394674d627fa800241 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Thu, 11 May 2017 06:22:39 -0400 Subject: Add tests for the first_files profile merges --- test/rebar_profiles_SUITE.erl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index ed492a9..9ffaf98 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -25,7 +25,8 @@ test_profile_erl_opts_order_2/1, test_profile_erl_opts_order_3/1, test_profile_erl_opts_order_4/1, - test_profile_erl_opts_order_5/1]). + test_profile_erl_opts_order_5/1, + first_files_exception/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -46,7 +47,8 @@ all() -> test_profile_erl_opts_order_2, test_profile_erl_opts_order_3, test_profile_erl_opts_order_4, - test_profile_erl_opts_order_5]. + test_profile_erl_opts_order_5, + first_files_exception]. init_per_suite(Config) -> application:start(meck), @@ -468,6 +470,25 @@ test_profile_erl_opts_order_5(Config) -> Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), warn_export_all = Opt. +first_files_exception(_Config) -> + RebarConfig = [{erl_first_files, ["c","a","b"]}, + {mib_first_files, ["c","a","b"]}, + {other, ["c","a","b"]}, + {profiles, + [{profile2, [{erl_first_files, ["a","e"]}, + {mib_first_files, ["a","e"]}, + {other, ["a","e"]} + ]}]}], + State = rebar_state:new(RebarConfig), + State1 = rebar_state:apply_profiles(State, [profile2]), + + %% Combine lists + ?assertEqual(["a","b","c","e"], rebar_state:get(State1, other)), + %% there is no specific reason not to dedupe "a" here aside from "this is how it is" + ?assertEqual(["c","a","b","a","e"], rebar_state:get(State1, erl_first_files)), + ?assertEqual(["c","a","b","a","e"], rebar_state:get(State1, mib_first_files)), + ok. + get_compiled_profile_erl_opts(Profiles, Config) -> AppDir = ?config(apps, Config), PStrs = [atom_to_list(P) || P <- Profiles], -- cgit v1.1 From 13bdb75b2961e1ae43e43e7c8d06bf463571d541 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Fri, 11 Aug 2017 13:58:13 -0400 Subject: Fix recursive profile merging in umbrella apps When a config file exists at the root of a project, defines a given configuration value for a given profile, and that a sub-application (umbrella app) also has the same profile defined with the same key (but different values), the configuration values of the sub-application's profile would get silently dropped. The problem being that when the function to merge profiles is applied recursively, it is applied to each profile (so it will merge on the keys test, prod, etc.) rather than to each of the values of each profile. This patch reworks the profile merging so that the current behaviour is respected overall (a profile cannot be cancelled by a subdep's non-existant profile since its value should have been ignored), but ensures that sub-deps' profiles are otherwise applied recursively with the proper rules: - dependencies favor prior values - plugins favor new values - erl_first_files combine the lists - relx uses the tuple merge algorithm - erl_opts has its own custom merge as well - otherwise the new value takes precedence A test has also been added. There is a risk of breakage in some applications that may have relied on the buggy behaviour to work, though at this time we are aware of none of them. --- test/rebar_profiles_SUITE.erl | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 9ffaf98..11aca6a 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -7,6 +7,7 @@ all/0, profile_new_key/1, profile_merge_keys/1, + profile_merge_umbrella_keys/1, explicit_profile_deduplicate_deps/1, implicit_profile_deduplicate_deps/1, all_deps_code_paths/1, @@ -33,7 +34,8 @@ -include_lib("kernel/include/file.hrl"). all() -> - [profile_new_key, profile_merge_keys, all_deps_code_paths, profile_merges, + [profile_new_key, profile_merge_keys, profile_merge_umbrella_keys, + all_deps_code_paths, profile_merges, explicit_profile_deduplicate_deps, implicit_profile_deduplicate_deps, same_profile_deduplication, stack_deduplication, add_to_profile, add_to_existing_profile, @@ -118,6 +120,35 @@ profile_merge_keys(Config) -> ,{dep, "a", "1.0.0"} ,{dep, "b", "2.0.0"}]}). +profile_merge_umbrella_keys(Config) -> + AppDir = ?config(apps, Config), + ct:pal("Path: ~s", [AppDir]), + Name = rebar_test_utils:create_random_name("profile_merge_umbrella_keys"), + Vsn = rebar_test_utils:create_random_vsn(), + SubAppDir = filename:join([AppDir, "apps", Name]), + + RebarConfig = [{vals, [{a,1},{b,1}]}, + {profiles, + [{ct, + [{vals, [{a,1},{b,2}]}]}]}], + + SubRebarConfig = [{vals, []}, + {profiles, [{ct, [{vals, [{c,1}]}]}]}], + + rebar_test_utils:create_app(SubAppDir, Name, Vsn, [kernel, stdlib]), + rebar_test_utils:create_config(SubAppDir, SubRebarConfig), + {ok, RebarConfigRead} = file:consult(rebar_test_utils:create_config(AppDir, RebarConfig)), + + {ok, State} = rebar_test_utils:run_and_check( + Config, RebarConfigRead, ["as", "ct", "compile"], return + ), + + [ProjectApp] = rebar_state:project_apps(State), + ?assertEqual(Name, binary_to_list(rebar_app_info:name(ProjectApp))), + Opts = rebar_app_info:opts(ProjectApp), + ?assertEqual([{a,1},{b,2},{b,1},{c,1}], dict:fetch(vals, Opts)), + ok. + explicit_profile_deduplicate_deps(Config) -> AppDir = ?config(apps, Config), -- cgit v1.1 From 2d5cd9c00cfa4e58066b48beee4057fdd52cc7be Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Wed, 1 Nov 2017 19:38:03 -0400 Subject: OTP-21 readiness, Full Unicode support This replaces all deprecated function usage by alternative ones based on a version switch enacted at compile time, preventing all warnings. This will likely introduce some possible runtime errors in using a Rebar3 compiled on OTP-20 or OTP-21 back in versions 19 and earlier, but we can't really work around that. A bunch of dependencies have been updated to support OTP-21 without warnings as well. --- test/rebar_profiles_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 11aca6a..324a771 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -542,7 +542,7 @@ get_compiled_profile_erl_opts(Profiles, Config) -> [default] -> ["compile"]; _ -> - ["as", string:join(PStrs, ","), "compile"] + ["as", rebar_string:join(PStrs, ","), "compile"] end, {ok, State} = rebar_test_utils:run_and_check( Config, RebarConfig, Command, {ok, [{app, Name}]}), -- cgit v1.1 From bf7ec3866f1819619286cc875fa88e1dc8bb9cfc Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Sun, 5 Nov 2017 22:24:58 -0500 Subject: Make debug_info rules clear Current rebar3 uses debug_info rules where debug_info is added by default, and no_debug_info prevents the default from being added, and removes any explicit debug_info, if any. The problem is that if 'no_debug_info' is anywhere in the config for a run, it cannot be removed even with other profiles. additionally, no_debug_info ignores special tuples like {debug_info, {Mod, Data}} and {debug_info_key, Key}, which can be used to add debug info and encrypt it (in lieu of plain debug_info) respectively. This patch makes it so that the following rules are in place: - the last option seen takes priority, allowing profile overrides by the ordering rules the compiler expects - the overriden options shall be explicitly deleted to avoid confusing the compiler - any option related to debug info seen last cancels any no_debug_info that preceded it - any no_debug_info option seen last cancels all of the other debug_info options - if debug_info is seen last, it cancels out {debug_info_key, Key} - if {debug_info_key, Key} is seen last, it cancels out debug_info - All other options are left untouched in that context (defines can still be expanded and so on) This should allow proper profile rules to be followed. Note that erl_opt profile merging puts precedence on the *last* element of a list, to match the compiler. --- test/rebar_profiles_SUITE.erl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 324a771..6afdc39 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -27,6 +27,7 @@ test_profile_erl_opts_order_3/1, test_profile_erl_opts_order_4/1, test_profile_erl_opts_order_5/1, + test_erl_opts_debug_info/1, first_files_exception/1]). -include_lib("common_test/include/ct.hrl"). @@ -50,6 +51,7 @@ all() -> test_profile_erl_opts_order_3, test_profile_erl_opts_order_4, test_profile_erl_opts_order_5, + test_erl_opts_debug_info, first_files_exception]. init_per_suite(Config) -> @@ -501,6 +503,30 @@ test_profile_erl_opts_order_5(Config) -> Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), warn_export_all = Opt. +test_erl_opts_debug_info(_Config) -> + ToOpts = fun(List) -> rebar_opts:erl_opts(dict:from_list([{erl_opts, List}])) end, + ?assertEqual([debug_info,a,b,c], + ToOpts([a,b,c])), + ?assertEqual([{debug_info,{mod,123}},a,b,c,debug_info], + ToOpts([{debug_info,{mod,123}},a,b,c,debug_info])), + ?assertEqual([a,b,debug_info,c], + ToOpts([no_debug_info,a,b,debug_info,c])), + ?assertEqual([a,b,c], + ToOpts([debug_info,a,b,no_debug_info,c])), + ?assertEqual([a,b,c,debug_info], + ToOpts([{debug_info_key, "12345"},a,b, + no_debug_info,c,debug_info])), + ?assertEqual([a,b,c], + ToOpts([{debug_info,{mod,123}},{debug_info_key, "12345"}, + a,no_debug_info,b,c,debug_info,no_debug_info])), + ?assertEqual([a,b,c,{debug_info_key,"123"}], + ToOpts([{debug_info_key, "12345"},a,b,no_debug_info,debug_info, + c,{debug_info_key, "123"}])), + ?assertEqual([{debug_info_key,"12345"},a,b,c,{debug_info,{mod,"123"}}], + ToOpts([debug_info,{debug_info_key,"12345"},a, + no_debug_info,b,c,{debug_info,{mod,"123"}}])), + ok. + first_files_exception(_Config) -> RebarConfig = [{erl_first_files, ["c","a","b"]}, {mib_first_files, ["c","a","b"]}, -- cgit v1.1 From abad0e14bb5a6ea5df21f2732bd72bf6efb0ca1e Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 23 Feb 2018 04:07:24 +0100 Subject: sort-as: show issue more clearly --- test/rebar_profiles_SUITE.erl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 6afdc39..9f7912d 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -28,7 +28,8 @@ test_profile_erl_opts_order_4/1, test_profile_erl_opts_order_5/1, test_erl_opts_debug_info/1, - first_files_exception/1]). + first_files_exception/1, + deduplication_stability/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -52,7 +53,8 @@ all() -> test_profile_erl_opts_order_4, test_profile_erl_opts_order_5, test_erl_opts_debug_info, - first_files_exception]. + first_files_exception, + deduplication_stability]. init_per_suite(Config) -> application:start(meck), @@ -133,7 +135,7 @@ profile_merge_umbrella_keys(Config) -> {profiles, [{ct, [{vals, [{a,1},{b,2}]}]}]}], - + SubRebarConfig = [{vals, []}, {profiles, [{ct, [{vals, [{c,1}]}]}]}], @@ -546,6 +548,17 @@ first_files_exception(_Config) -> ?assertEqual(["c","a","b","a","e"], rebar_state:get(State1, mib_first_files)), ok. +deduplication_stability(_Config) -> + ?assertEqual([default,all_deps_test], rebar_state:deduplicate([default,all_deps_test])), + ?assertEqual([default,profile1,profile2], rebar_state:deduplicate([default,profile1,profile2])), + ?assertEqual([default,bar,foo], rebar_state:deduplicate([default,bar,foo,bar])), %% master wants [default,foo,bar] + ?assertEqual([default,test,bar], rebar_state:deduplicate([default,test,bar])), + ?assertEqual([default,test,bar], rebar_state:deduplicate([default,test,bar,test])), + ?assertEqual([default,profile1], rebar_state:deduplicate([default,profile1,profile1,profile1])), + ?assertEqual([default,a,b,c,d,e], rebar_state:deduplicate([default,a,b,c,d,e,a,e,b])), + ?assertEqual([default,test], rebar_state:deduplicate([default,test])), + ok. + get_compiled_profile_erl_opts(Profiles, Config) -> AppDir = ?config(apps, Config), PStrs = [atom_to_list(P) || P <- Profiles], -- cgit v1.1 From 6aeff6300bf8986079ac6e8f83fa37150e239810 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 23 Feb 2018 12:50:29 +0100 Subject: Revert "sort-as: show issue more clearly" This reverts commit 4ad1db97336a3ac070880876ada07d4c7b769327. --- test/rebar_profiles_SUITE.erl | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 9f7912d..6afdc39 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -28,8 +28,7 @@ test_profile_erl_opts_order_4/1, test_profile_erl_opts_order_5/1, test_erl_opts_debug_info/1, - first_files_exception/1, - deduplication_stability/1]). + first_files_exception/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -53,8 +52,7 @@ all() -> test_profile_erl_opts_order_4, test_profile_erl_opts_order_5, test_erl_opts_debug_info, - first_files_exception, - deduplication_stability]. + first_files_exception]. init_per_suite(Config) -> application:start(meck), @@ -135,7 +133,7 @@ profile_merge_umbrella_keys(Config) -> {profiles, [{ct, [{vals, [{a,1},{b,2}]}]}]}], - + SubRebarConfig = [{vals, []}, {profiles, [{ct, [{vals, [{c,1}]}]}]}], @@ -548,17 +546,6 @@ first_files_exception(_Config) -> ?assertEqual(["c","a","b","a","e"], rebar_state:get(State1, mib_first_files)), ok. -deduplication_stability(_Config) -> - ?assertEqual([default,all_deps_test], rebar_state:deduplicate([default,all_deps_test])), - ?assertEqual([default,profile1,profile2], rebar_state:deduplicate([default,profile1,profile2])), - ?assertEqual([default,bar,foo], rebar_state:deduplicate([default,bar,foo,bar])), %% master wants [default,foo,bar] - ?assertEqual([default,test,bar], rebar_state:deduplicate([default,test,bar])), - ?assertEqual([default,test,bar], rebar_state:deduplicate([default,test,bar,test])), - ?assertEqual([default,profile1], rebar_state:deduplicate([default,profile1,profile1,profile1])), - ?assertEqual([default,a,b,c,d,e], rebar_state:deduplicate([default,a,b,c,d,e,a,e,b])), - ?assertEqual([default,test], rebar_state:deduplicate([default,test])), - ok. - get_compiled_profile_erl_opts(Profiles, Config) -> AppDir = ?config(apps, Config), PStrs = [atom_to_list(P) || P <- Profiles], -- cgit v1.1 From cfe6dfcca5d6526d835531a81cb5bdc1a21c17b3 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 23 Feb 2018 13:08:02 +0100 Subject: sort-as: bar profile specializes dep "b" into a version anterior to what test profile wants --- test/rebar_profiles_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 6afdc39..ddc3cf1 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -211,7 +211,7 @@ implicit_profile_deduplicate_deps(Config) -> rebar_test_utils:run_and_check(Config, RebarConfig, ["as", "test,bar", "eunit"], {ok, [{app, Name} ,{dep, "a", "1.0.0"} - ,{dep, "b", "2.0.0"}]}). + ,{dep, "b", "1.0.0"}]}). all_deps_code_paths(Config) -> AppDir = ?config(apps, Config), -- cgit v1.1 From 543fe579a6d7c71fb4ed6a898540b573f6255dd0 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Fri, 20 Apr 2018 21:03:05 -0400 Subject: Fix precedence rules of erl_opts for test profile When adding the 'TEST' macro to the test profile, we mistakenly sourced the erl_opts values from the base profile rather than the test profile itself. This means that in cases where the base profile set an option such as 'no_debug_info' and a profile overrode it with 'debug_info', the default options would get injected within the test profile, and broke the precedence rules, yielding incompatible values. This patch fixes things by adding the macro to the values sourced from the test profile itself, fixing the issue. --- test/rebar_profiles_SUITE.erl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/rebar_profiles_SUITE.erl') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index ddc3cf1..512832a 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -28,6 +28,7 @@ test_profile_erl_opts_order_4/1, test_profile_erl_opts_order_5/1, test_erl_opts_debug_info/1, + test_profile_erl_opts_precedence/1, first_files_exception/1]). -include_lib("common_test/include/ct.hrl"). @@ -52,6 +53,7 @@ all() -> test_profile_erl_opts_order_4, test_profile_erl_opts_order_5, test_erl_opts_debug_info, + test_profile_erl_opts_precedence, first_files_exception]. init_per_suite(Config) -> @@ -527,6 +529,36 @@ test_erl_opts_debug_info(_Config) -> no_debug_info,b,c,{debug_info,{mod,"123"}}])), ok. +test_profile_erl_opts_precedence(Config) -> + AppDir = ?config(apps, Config), + Name = rebar_test_utils:create_random_name("profile_new_key_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + RebarConfig = [{erl_opts, [no_debug_info]}, + {profiles, [ + {test, [{erl_opts, [debug_info, {d,'HI'}]}]}, + {other, [{erl_opts, [debug_info, {d,'HI'}]}]} + ]}], + {ok, State1} = rebar_test_utils:run_and_check( + Config, RebarConfig, ["as", "test", "compile"], return + ), + {ok, State2} = rebar_test_utils:run_and_check( + Config, RebarConfig, ["as", "other", "compile"], return + ), + {ok, State3} = rebar_test_utils:run_and_check( + Config, RebarConfig, ["compile"], return + ), + Opts1 = rebar_state:opts(State1), + Opts2 = rebar_state:opts(State2), + Opts3 = rebar_state:opts(State3), + ErlOpts1 = rebar_opts:erl_opts(Opts1), + ErlOpts2 = rebar_opts:erl_opts(Opts2), + ErlOpts3 = rebar_opts:erl_opts(Opts3), + ?assertEqual([{d,'TEST'}, debug_info, {d,'HI'}], ErlOpts1), + ?assertEqual([debug_info, {d,'HI'}], ErlOpts2), + ?assertEqual([], ErlOpts3), + ok. + first_files_exception(_Config) -> RebarConfig = [{erl_first_files, ["c","a","b"]}, {mib_first_files, ["c","a","b"]}, -- cgit v1.1