summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_cover.erl43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/rebar_prv_cover.erl b/src/rebar_prv_cover.erl
index 9772e96..7c2597b 100644
--- a/src/rebar_prv_cover.erl
+++ b/src/rebar_prv_cover.erl
@@ -308,23 +308,16 @@ cover_compile(State, Dirs) ->
lists:foreach(fun(Dir) ->
case file:list_dir(Dir) of
{ok, Files} ->
- Files2 = [F || F <- Files, filename:extension(F) == ".beam"],
- lists:foreach(fun(File) ->
- case lists:any(fun (Excl) ->
- File =:= (atom_to_list(Excl) ++ ".beam")
- end, ExclMods) of
- true ->
- ?DEBUG("cover ignoring ~p ~p", [Dir, File]);
- _ ->
- ?DEBUG("cover compiling ~p ~p", [Dir, File]),
- case catch(cover:compile_beam(filename:join(Dir, File))) of
- {error, Reason} ->
- ?WARN("Cover compilation failed: ~p", [Reason]);
- {ok, _} ->
- ok
- end
- end
- end, Files2);
+ ?DEBUG("cover compiling ~p", [Dir]),
+ [cover_compile_file(filename:join(Dir, File))
+ || File <- Files,
+ filename:extension(File) == ".beam",
+ not is_ignored(Dir, File, ExclMods)],
+ ok;
+ {error, eacces} ->
+ ?WARN("Directory ~p not readable, modules will not be included in coverage", [Dir]);
+ {error, enoent} ->
+ ?WARN("Directory ~p not found", [Dir]);
{error, Reason} ->
?WARN("Directory ~p error ~p", [Dir, Reason])
end
@@ -332,6 +325,22 @@ cover_compile(State, Dirs) ->
rebar_utils:cleanup_code_path(rebar_state:code_paths(State, default)),
ok.
+is_ignored(Dir, File, ExclMods) ->
+ Ignored = lists:any(fun(Excl) ->
+ File =:= atom_to_list(Excl) ++ ".beam"
+ end,
+ ExclMods),
+ Ignored andalso ?DEBUG("cover ignoring ~p ~p", [Dir, File]),
+ Ignored.
+
+cover_compile_file(FileName) ->
+ case catch(cover:compile_beam(FileName)) of
+ {error, Reason} ->
+ ?WARN("Cover compilation failed: ~p", [Reason]);
+ {ok, _} ->
+ ok
+ end.
+
app_dirs(Apps) ->
lists:foldl(fun app_ebin_dirs/2, [], Apps).