From 8946f723fbe3e0219bb0c5ceb7c0142ec1aee797 Mon Sep 17 00:00:00 2001 From: Sergey Yelin Date: Thu, 12 Dec 2019 10:56:47 +0300 Subject: [PATCH 1/3] Add `--statistics` option to dialyzer command In some cases its nice to have dialyzer statistics out of box without any additional steps. --- src/rebar_prv_dialyzer.erl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index 1de978be..aed24fd9 100644 --- a/src/rebar_prv_dialyzer.erl +++ b/src/rebar_prv_dialyzer.erl @@ -27,7 +27,8 @@ init(State) -> {base_plt_location, undefined, "base-plt-location", string, "The location of base PLT file, defaults to $HOME/.cache/rebar3"}, {plt_location, undefined, "plt-location", string, "The location of the PLT file, defaults to the profile's base directory"}, {plt_prefix, undefined, "plt-prefix", string, "The prefix to the PLT file, defaults to \"rebar3\"" }, - {base_plt_prefix, undefined, "base-plt-prefix", string, "The prefix to the base PLT file, defaults to \"rebar3\"" }], + {base_plt_prefix, undefined, "base-plt-prefix", string, "The prefix to the base PLT file, defaults to \"rebar3\"" }, + {statistics, undefined, "statistics", boolean, "Print information about the progress of execution. Default: false" }], State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, {module, ?MODULE}, {bare, true}, @@ -481,12 +482,15 @@ proj_files(State) -> get_files(State, Apps, PltApps, [], PltMods). run_dialyzer(State, Opts, Output) -> + {Args, _} = rebar_state:command_parsed_args(State), + Timing = proplists:get_bool(statistics, Args), %% dialyzer may return callgraph warnings when get_warnings is false case proplists:get_bool(get_warnings, Opts) of true -> WarningsList = get_config(State, warnings, []), Opts2 = [{warnings, legacy_warnings(WarningsList)}, - {check_plt, false} | + {check_plt, false}, + {timing, Timing} | Opts], ?DEBUG("Running dialyzer with options: ~p~n", [Opts2]), Warnings = format_warnings(rebar_state:opts(State), From 537283debb121ae309139b49f46e8dc2c63406e8 Mon Sep 17 00:00:00 2001 From: Sergey Yelin Date: Mon, 16 Dec 2019 12:12:09 +0300 Subject: [PATCH 2/3] Add comment for option naming --- src/rebar_prv_dialyzer.erl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index aed24fd9..e44c2875 100644 --- a/src/rebar_prv_dialyzer.erl +++ b/src/rebar_prv_dialyzer.erl @@ -483,6 +483,11 @@ proj_files(State) -> run_dialyzer(State, Opts, Output) -> {Args, _} = rebar_state:command_parsed_args(State), + %% dialyzer uses command-line option `--statistics` for enabling + %% additional info about progress of execution, but internally + %% this option has name `timing`. + %% NOTE: Option `timing` accept boolean() or 'debug', but here we support + %% only boolean(). Timing = proplists:get_bool(statistics, Args), %% dialyzer may return callgraph warnings when get_warnings is false case proplists:get_bool(get_warnings, Opts) of From 2fc7ebf3ee5b278ee8eefdf97059f5228302837c Mon Sep 17 00:00:00 2001 From: Sergey Yelin Date: Mon, 16 Dec 2019 12:12:33 +0300 Subject: [PATCH 3/3] Add new option to test --- test/rebar_dialyzer_SUITE.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/rebar_dialyzer_SUITE.erl b/test/rebar_dialyzer_SUITE.erl index 8577a323..724f9d06 100644 --- a/test/rebar_dialyzer_SUITE.erl +++ b/test/rebar_dialyzer_SUITE.erl @@ -335,7 +335,8 @@ cli_args(Config) -> "--plt-location=" ++ Location, "--base-plt-location=" ++ BasePltLocation, "--plt-prefix=" ++ Prefix, - "--base-plt-prefix=" ++ BasePrefix], + "--base-plt-prefix=" ++ BasePrefix, + "--statistics"], {ok, [{app, Name1}, {app, Name2}]}), ErtsFiles = erts_files(),