Skip to content

Commit 079ad8b

Browse files
committed
rabbit_common: Remove 'cover' related code from 'rabbit_misc'
This is very old code that is likely no longer used. Removing it helps avoid depending on cover.
1 parent fa5b475 commit 079ad8b

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

deps/rabbit_common/src/rabbit_misc.erl

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
-export([table_lookup/2, set_table_value/4, amqp_table/1, to_amqp_table/1]).
2727
-export([r/3, r/2, r_arg/4, rs/1,
2828
queue_resource/2, exchange_resource/2]).
29-
-export([enable_cover/0, report_cover/0]).
30-
-export([enable_cover/1, report_cover/1]).
31-
-export([start_cover/1]).
3229
-export([throw_on_error/2, with_exit_handler/2, is_abnormal_exit/1,
3330
filter_exit_map/2]).
3431
-export([ensure_ok/2]).
@@ -165,11 +162,6 @@
165162
{invalid_type, rabbit_framing:amqp_field_type()}) |
166163
rabbit_types:r(K) when is_subtype(K, atom()).
167164
-spec rs(rabbit_types:r(atom())) -> string().
168-
-spec enable_cover() -> ok_or_error().
169-
-spec start_cover([{string(), string()} | string()]) -> 'ok'.
170-
-spec report_cover() -> 'ok'.
171-
-spec enable_cover([file:filename() | atom()]) -> ok_or_error().
172-
-spec report_cover([file:filename() | atom()]) -> 'ok'.
173165
-spec throw_on_error
174166
(atom(), thunk(rabbit_types:error(any()) | {ok, A} | A)) -> A.
175167
-spec with_exit_handler(thunk(A), thunk(A)) -> A.
@@ -449,59 +441,6 @@ queue_resource(VHostPath, Name) ->
449441
exchange_resource(VHostPath, Name) ->
450442
r(VHostPath, exchange, Name).
451443

452-
enable_cover() -> enable_cover(["."]).
453-
454-
enable_cover(Dirs) ->
455-
lists:foldl(fun (Dir, ok) ->
456-
case cover:compile_beam_directory(
457-
filename:join(lists:concat([Dir]),"ebin")) of
458-
{error, _} = Err -> Err;
459-
_ -> ok
460-
end;
461-
(_Dir, Err) ->
462-
Err
463-
end, ok, Dirs).
464-
465-
start_cover(NodesS) ->
466-
{ok, _} = cover:start([rabbit_nodes_common:make(N) || N <- NodesS]),
467-
ok.
468-
469-
report_cover() -> report_cover(["."]).
470-
471-
report_cover(Dirs) -> [report_cover1(lists:concat([Dir])) || Dir <- Dirs], ok.
472-
473-
report_cover1(Root) ->
474-
Dir = filename:join(Root, "cover"),
475-
ok = filelib:ensure_dir(filename:join(Dir, "junk")),
476-
lists:foreach(fun (F) -> file:delete(F) end,
477-
filelib:wildcard(filename:join(Dir, "*.html"))),
478-
{ok, SummaryFile} = file:open(filename:join(Dir, "summary.txt"), [write]),
479-
{CT, NCT} =
480-
lists:foldl(
481-
fun (M,{CovTot, NotCovTot}) ->
482-
{ok, {M, {Cov, NotCov}}} = cover:analyze(M, module),
483-
ok = report_coverage_percentage(SummaryFile,
484-
Cov, NotCov, M),
485-
{ok,_} = cover:analyze_to_file(
486-
M,
487-
filename:join(Dir, atom_to_list(M) ++ ".html"),
488-
[html]),
489-
{CovTot+Cov, NotCovTot+NotCov}
490-
end,
491-
{0, 0},
492-
lists:sort(cover:modules())),
493-
ok = report_coverage_percentage(SummaryFile, CT, NCT, 'TOTAL'),
494-
ok = file:close(SummaryFile),
495-
ok.
496-
497-
report_coverage_percentage(File, Cov, NotCov, Mod) ->
498-
io:fwrite(File, "~6.2f ~tp~n",
499-
[if
500-
Cov+NotCov > 0 -> 100.0*Cov/(Cov+NotCov);
501-
true -> 100.0
502-
end,
503-
Mod]).
504-
505444
%% @doc Halts the emulator returning the given status code to the os.
506445
%% On Windows this function will block indefinitely so as to give the io
507446
%% subsystem time to flush stdout completely.

0 commit comments

Comments
 (0)