diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-08-27 07:26:26 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2016-08-27 07:26:26 -0400 |
commit | 03412438fac0d28a61001fbea67ea23766dedf33 (patch) | |
tree | d01d6c9748e4b11c2ed0a7cb7ba0eb2c0293f48e /src | |
parent | 8ee9cc89969afd79bf8687dcdf978f1a09e01d48 (diff) | |
parent | 4ff52d991eb1240acbe82859d643295076f90727 (diff) |
Merge branch 'cover_excl_mods' of https://github.com/lpgauth/rebar3 into lpgauth-cover_excl_mods
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_cover.erl | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/rebar_prv_cover.erl b/src/rebar_prv_cover.erl index 464967b..9772e96 100644 --- a/src/rebar_prv_cover.erl +++ b/src/rebar_prv_cover.erl @@ -303,18 +303,30 @@ cover_compile(State, Dirs) -> {ok, CoverPid} = start_cover(), %% redirect cover output true = redirect_cover_output(State, CoverPid), + ExclMods = rebar_state:get(State, cover_excl_mods, []), + lists:foreach(fun(Dir) -> - ?DEBUG("cover compiling ~p", [Dir]), - case catch(cover:compile_beam_directory(Dir)) of - {error, eacces} -> - ?WARN("Directory ~p not readable, modules will not be included in coverage", [Dir]); - {error, enoent} -> - ?WARN("Directory ~p not found", [Dir]); - {'EXIT', {Reason, _}} -> - ?WARN("Cover compilation for directory ~p failed: ~p", [Dir, Reason]); - Results -> - %% print any warnings about modules that failed to cover compile - lists:foreach(fun print_cover_warnings/1, lists:flatten(Results)) + 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); + {error, Reason} -> + ?WARN("Directory ~p error ~p", [Dir, Reason]) end end, Dirs), rebar_utils:cleanup_code_path(rebar_state:code_paths(State, default)), @@ -349,10 +361,6 @@ redirect_cover_output(State, CoverPid) -> [append]), group_leader(F, CoverPid). -print_cover_warnings({ok, _}) -> ok; -print_cover_warnings({error, Error}) -> - ?WARN("Cover compilation failed: ~p", [Error]). - write_coverdata(State, Task) -> DataDir = cover_dir(State), ok = filelib:ensure_dir(filename:join([DataDir, "dummy.log"])), |