From 0e606138c5cd9a636a1954945fa0a03c267ef9c6 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Tue, 24 Feb 2015 20:36:15 -0800 Subject: print warning if cover can't annotate source and skip file --- src/rebar_prv_cover.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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"]). -- cgit v1.1