summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2015-02-24 20:36:15 -0800
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-03 01:57:55 -0800
commit0e606138c5cd9a636a1954945fa0a03c267ef9c6 (patch)
tree1e7288a87dcf4517bd5ab2ec497ba4c847927f29
parenteb93bb000ae03d81788032f22c895a74a95f3ca6 (diff)
print warning if cover can't annotate source and skip file
-rw-r--r--src/rebar_prv_cover.erl10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/rebar_prv_cover.erl b/src/rebar_prv_cover.erl
index 4bcef29..791e4e9 100644
--- a/src/rebar_prv_cover.erl
+++ b/src/rebar_prv_cover.erl
@@ -150,12 +150,20 @@ analyze_to_file(Mod, State, Task) ->
ok = filelib:ensure_dir(filename:join([TaskDir, "dummy.html"])),
case code:ensure_loaded(Mod) of
{module, _} ->
- cover:analyze_to_file(Mod, mod_to_filename(TaskDir, Mod), [html]);
+ write_file(Mod, mod_to_filename(TaskDir, Mod));
{error, _} ->
?WARN("Can't load module ~ts.", [Mod]),
{ok, []}
end.
+write_file(Mod, FileName) ->
+ case cover:analyze_to_file(Mod, FileName, [html]) of
+ {ok, File} -> {ok, File};
+ {error, Reason} ->
+ ?WARN("Couldn't write annotated file for module ~p for reason ~p", [Mod, Reason]),
+ {ok, []}
+ end.
+
mod_to_filename(TaskDir, M) ->
filename:join([TaskDir, atom_to_list(M) ++ ".html"]).