summaryrefslogtreecommitdiff
path: root/test/rebar_profiles_SUITE.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-11-05 22:24:58 -0500
committerFred Hebert <mononcqc@ferd.ca>2017-11-20 14:56:06 -0500
commitbf7ec3866f1819619286cc875fa88e1dc8bb9cfc (patch)
treec4c1275a3ce82eb13829eb8cfa4d7b0e4d6d0102 /test/rebar_profiles_SUITE.erl
parent26d30a95fa8ecba5d40a4627a7b436f58b53cb0e (diff)
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.
Diffstat (limited to 'test/rebar_profiles_SUITE.erl')
-rw-r--r--test/rebar_profiles_SUITE.erl26
1 files changed, 26 insertions, 0 deletions
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"]},