Created
August 24, 2012 20:49
-
-
Save zkessin/3455466 to your computer and use it in GitHub Desktop.
Erlang Code Coverage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(cover). | |
-export([ cover/0]). | |
cover()-> | |
io:format("~n********************************************************************************~n"), | |
io:format("Running Tests~n~n"), | |
cover:start(), | |
_R = cover:compile_beam_directory("ebin/"), | |
Modules = cover:modules(), | |
[eunit:test(Module) || Module <- Modules], | |
Coverage = [cover:analyse(Module, calls, line) || Module <- Modules], | |
L = lists:merge([Lines || {ok, Lines} <- Coverage]), | |
NonTestModules = lists:filter(fun({{Module, _}, _} )-> | |
Es = lists:reverse(string:tokens(atom_to_list(Module),"_") ), | |
lists:nth(1, Es) =/= "test" | |
end,L), | |
Zeros = lists:filter(fun ({{_Module, _Line}, Count}) -> | |
Count =:= 0 | |
end, NonTestModules), | |
[io:format("src/~p.erl:~p: No Code Coverage~n",[Module, Line])|| {{Module, Line}, 0} <-Zeros], | |
init:stop(). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment