diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2019-04-05 09:57:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 09:57:32 -0400 |
commit | df3a88abf76f2096e4fe47f9137ce3dba713d4f6 (patch) | |
tree | 6d1bd0ab1165755bc16da178dd86725de83f45d0 | |
parent | 0843c19bceca2f18c2b84129551a412135cc9608 (diff) | |
parent | e56eaa71bb13230cca807998fdd8ce70b47de7d7 (diff) |
Merge pull request #2048 from jkakar/jkakar/quieter-test-output
rebar3 eunit: Hide slowest tests profile output by default
-rw-r--r-- | src/rebar_prv_eunit.erl | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl index 0b00e89..4764439 100644 --- a/src/rebar_prv_eunit.erl +++ b/src/rebar_prv_eunit.erl @@ -424,17 +424,35 @@ resolve_eunit_opts(State) -> true -> set_verbose(EUnitOpts); false -> EUnitOpts end, - IsVerbose = lists:member(verbose, EUnitOpts1), - case proplists:get_value(eunit_formatters, EUnitOpts1, not IsVerbose) of - true -> custom_eunit_formatters(EUnitOpts1); - false -> EUnitOpts1 + EUnitOpts2 = case proplists:get_value(profile, Opts, false) of + true -> set_profile(EUnitOpts1); + false -> EUnitOpts1 + end, + IsVerbose = lists:member(verbose, EUnitOpts2), + case proplists:get_value(eunit_formatters, Opts, not IsVerbose) of + true -> custom_eunit_formatters(EUnitOpts2); + false -> EUnitOpts2 end. custom_eunit_formatters(Opts) -> + ReportOpts = custom_eunit_report_options(Opts), %% If `report` is already set then treat that like `eunit_formatters` is false case lists:keymember(report, 1, Opts) of true -> Opts; - false -> [no_tty, {report, {eunit_progress, [colored, profile]}} | Opts] + false -> [no_tty, {report, {eunit_progress, ReportOpts}} | Opts] + end. + +custom_eunit_report_options(Opts) -> + case lists:member(profile, Opts) of + true -> [colored, profile]; + false -> [colored] + end. + +set_profile(Opts) -> + %% if `profile` is already set don't set it again + case lists:member(profile, Opts) of + true -> Opts; + false -> [profile] ++ Opts end. set_verbose(Opts) -> @@ -508,6 +526,7 @@ eunit_opts(_State) -> {application, undefined, "application", string, help(app)}, {cover, $c, "cover", boolean, help(cover)}, {cover_export_name, undefined, "cover_export_name", string, help(cover_export_name)}, + {profile, $p, "profile", boolean, help(profile)}, {dir, $d, "dir", string, help(dir)}, {file, $f, "file", string, help(file)}, {module, $m, "module", string, help(module)}, @@ -521,6 +540,7 @@ eunit_opts(_State) -> help(app) -> "Comma separated list of application test suites to run. Equivalent to `[{application, App}]`."; help(cover) -> "Generate cover data. Defaults to false."; help(cover_export_name) -> "Base name of the coverdata file to write"; +help(profile) -> "Show the slowest tests. Defaults to false."; help(dir) -> "Comma separated list of dirs to load tests from. Equivalent to `[{dir, Dir}]`."; help(file) -> "Comma separated list of files to load tests from. Equivalent to `[{file, File}]`."; help(module) -> "Comma separated list of modules to load tests from. Equivalent to `[{module, Module}]`."; |