summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_prv_dialyzer.erl23
-rw-r--r--test/rebar_release_SUITE.erl57
-rw-r--r--test/rebar_test_utils.erl15
3 files changed, 87 insertions, 8 deletions
diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl
index 2e5728a..834eb98 100644
--- a/src/rebar_prv_dialyzer.erl
+++ b/src/rebar_prv_dialyzer.erl
@@ -397,7 +397,7 @@ run_dialyzer(State, Opts, Output) ->
case proplists:get_bool(get_warnings, Opts) of
true ->
WarningsList = get_config(State, warnings, []),
- Opts2 = [{warnings, WarningsList},
+ Opts2 = [{warnings, legacy_warnings(WarningsList)},
{check_plt, false} |
Opts],
?DEBUG("Running dialyzer with options: ~p~n", [Opts2]),
@@ -412,6 +412,14 @@ run_dialyzer(State, Opts, Output) ->
{0, State}
end.
+legacy_warnings(Warnings) ->
+ case dialyzer_version() of
+ TupleVsn when TupleVsn < {2, 8, 0} ->
+ [Warning || Warning <- Warnings, Warning =/= unknown];
+ _ ->
+ Warnings
+ end.
+
format_warnings(Output, Warnings) ->
Warnings1 = rebar_dialyzer_format:format_warnings(Warnings),
console_warnings(Warnings1),
@@ -475,3 +483,16 @@ collect_nested_dependent_apps(App, Seen) ->
end
end
end.
+
+dialyzer_version() ->
+ _ = application:load(dialyzer),
+ {ok, Vsn} = application:get_key(dialyzer, vsn),
+ case string:tokens(Vsn, ".") of
+ [Major, Minor] ->
+ version_tuple(Major, Minor, "0");
+ [Major, Minor, Patch | _] ->
+ version_tuple(Major, Minor, Patch)
+ end.
+
+version_tuple(Major, Minor, Patch) ->
+ {list_to_integer(Major), list_to_integer(Minor), list_to_integer(Patch)}.
diff --git a/test/rebar_release_SUITE.erl b/test/rebar_release_SUITE.erl
index 29856c7..1125a7e 100644
--- a/test/rebar_release_SUITE.erl
+++ b/test/rebar_release_SUITE.erl
@@ -10,7 +10,8 @@ all() -> [release,
profile_ordering_sys_config_extend,
profile_ordering_sys_config_extend_3_tuple_merge,
extend_release,
- user_output_dir, profile_overlays].
+ user_output_dir, profile_overlays,
+ overlay_vars].
init_per_testcase(Case, Config0) ->
Config = rebar_test_utils:init_rebar_state(Config0),
@@ -215,3 +216,57 @@ profile_overlays(Config) ->
{dir, filename:join(ReleaseDir, "otherrandomdir")},
{dir, filename:join(ReleaseDir, "randomdir")}]}
).
+
+overlay_vars(Config) ->
+ AppDir = ?config(apps, Config),
+ Name = ?config(name, Config),
+ Vsn = "1.0.0",
+ {ok, RebarConfig} =
+ file:consult(rebar_test_utils:create_config(AppDir,
+ [{relx, [{release, {list_to_atom(Name), Vsn},
+ [list_to_atom(Name)]},
+ {overlay, [
+ {template, filename:join([AppDir, "config/app.config"]),
+ "releases/{{release_version}}/sys.config"}
+ ]},
+ {overlay_vars, filename:join([AppDir, "config/vars.config"])},
+ {lib_dirs, [AppDir]}]}
+ ])),
+
+ ok = filelib:ensure_dir(filename:join([AppDir, "config", "dummy"])),
+
+ OverlayVars = [{var_int, 1},
+ {var_string, "\"test\""},
+ {var_bin_string, "<<\"test\">>"},
+ {var_tuple, "{t, ['atom']}"},
+ {var_list, "[a, b, c, 'd']"},
+ {var_bin, "<<23, 24, 25>>"}],
+ rebar_test_utils:create_config(AppDir,
+ filename:join([AppDir, "config", "vars.config"]),
+ OverlayVars),
+
+ AppConfig = [[{var_int, {{var_int}}},
+ {var_string, {{{var_string}}}},
+ {var_bin_string, {{{var_bin_string}}}},
+ {var_tuple, {{{var_tuple}}}},
+ {var_list, {{{var_list}}}},
+ {var_bin, {{{var_bin}}}}]],
+ rebar_test_utils:create_config(AppDir,
+ filename:join([AppDir, "config", "app.config"]),
+ AppConfig),
+
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig,
+ ["release"],
+ {ok, [{release, list_to_atom(Name), Vsn, false}]}),
+
+ %% now consult the sys.config file to make sure that is has the expected
+ %% format
+ ExpectedSysconfig = [{var_int, 1},
+ {var_string, "test"},
+ {var_bin_string, <<"test">>},
+ {var_tuple, {t, ['atom']}},
+ {var_list, [a, b, c, 'd']},
+ {var_bin, <<23, 24, 25>>}],
+ {ok, [ExpectedSysconfig]} = file:consult(filename:join([AppDir, "_build/default/rel",
+ Name, "releases", Vsn, "sys.config"])).
diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl
index 3943db7..5187bda 100644
--- a/test/rebar_test_utils.erl
+++ b/test/rebar_test_utils.erl
@@ -3,8 +3,8 @@
-include_lib("eunit/include/eunit.hrl").
-export([init_rebar_state/1, init_rebar_state/2, run_and_check/4, check_results/3]).
-export([expand_deps/2, flat_deps/1, top_level_deps/1]).
--export([create_app/4, create_eunit_app/4, create_empty_app/4, create_config/2,
- package_app/3]).
+-export([create_app/4, create_eunit_app/4, create_empty_app/4,
+ create_config/2, create_config/3, package_app/3]).
-export([create_random_name/1, create_random_vsn/0, write_src_file/2]).
%%%%%%%%%%%%%%
@@ -104,11 +104,14 @@ create_empty_app(AppDir, Name, Vsn, Deps) ->
%% each of which will be dumped as a consult file. For example, the list
%% `[a, b, c]' will return the consult file `a. b. c.'.
create_config(AppDir, Contents) ->
- Conf = filename:join([AppDir, "rebar.config"]),
- ok = filelib:ensure_dir(Conf),
+ ConfFilename = filename:join([AppDir, "rebar.config"]),
+ create_config(AppDir, ConfFilename, Contents).
+
+create_config(_AppDir, ConfFilename, Contents) ->
+ ok = filelib:ensure_dir(ConfFilename),
Config = lists:flatten([io_lib:fwrite("~p.~n", [Term]) || Term <- Contents]),
- ok = ec_file:write(Conf, Config),
- Conf.
+ ok = ec_file:write(ConfFilename, Config),
+ ConfFilename.
%% @doc Util to create a random variation of a given name.
create_random_name(Name) ->